Dark Mode On/Off

# C++ Program To Find Max Number Among Given Three Number Using If/Else Statements

In this program, the user is asked to enter three numbers.

Then this program finds out the largest number among the three numbers entered by the user and displays it with the proper message. This program can be used in more than one way.

## Find Max Number Among Given Three Number Using If/Else Statements

In the above program, firstly, a is compared to b. If a is greater than b, then it is compared to c. If it is greater than c as well, that means a is the largest number and if not, then c is the largest number. If a is not greater than b, that means b is greater than a. Then b is compared to c. If it is greater than c, that means b is the largest number and if not, then c is the largest number.

``````#include<bits/stdc++.h>
using namespace std;

int max(int num1,int num2,int num3){
if(num1>=num2 && num1>=num3){
return num1;
}
else if(num2>=num1 && num2>=num3){
return num2;
}
else{
return num3;
}
}

int main(){
int a,b,c;
cout<<"Enter the three numbers:-";
cin>>a>>b>>c;
cout<<"The maximum number is "<<max(a,b,c);
return 0;
}``````

Enter the three numbers:-17 6 9
The maximum number is 17

## Conclusion

Here, in this tutorial we have that can we find the maximum number among the three given numbers by using the if-else statements.

Want to learn coding?
Try our new interactive courses.
Over 20,000+ students enrolled.