Maximum of 3 numbers: Mrs. Anitha , our favourite Maths teacher wanted to teach her new batch of students to find maximum among three numbers.
Write a program to accept 3 integers and find maximum among 3 numbers using functions and pointers.
Function Specification:
int maximum(int *a,int *b, int *c)
This function returns the maximum among 3 numbers.
Input Format:
Input consists of 3 integers.
Output Format:
Refer the sample output.
[All text in bold corresponds to input and the rest corresponds to output.]
Sample Input and Output :
Enter the value of a
5
Enter the value of b
6
Enter the value of c
2
Maximum element is 6
Solution
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
int a, b, c;
cout << "Enter the value of a\n";
cin >> a;
cout << "Enter the value of b\n";
cin >> b;
cout << "Enter the value of c\n";
cin >> c;
if (a > b && a > c)
{
cout << "Maximum element is " << a;
}
else if (b > a && b > c)
{
cout << "Maximum element is " << b;
}
else
{
cout << "Maximum element is " << c;
}
return 0;
}Happy Learning – If you require any further information, feel free to contact me.
![[Solved] Maximum of 3 numbers with C++ [Solved] Maximum of 3 numbers with C++](https://realcoder.techss24.com/wp-content/uploads/2022/07/Solved-Maximum-of-3-numbers-with-C.png)
![[Solved] Auditions with Java, C++](https://realcoder.techss24.com/wp-content/uploads/2022/07/Solved-Auditions-with-Java-C-300x200.png)
![[Solved] Decorative Tiles with Java, C++](https://realcoder.techss24.com/wp-content/uploads/2022/07/Solved-Decorative-Tiles-with-Java-C-300x200.png)
![[Solved] The BFS traversal Contest Problem](https://realcoder.techss24.com/wp-content/uploads/2022/06/Solved-The-BFS-traversal-Contest-Problem-300x200.png)