Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Finding Max using if and else if
if (a1>a2) {
if (a1 > a3) {
if (a1 > a4) {
if (a1 > a5) {
cout << a1 << " is maximum";
}
}
}
}
else if (a2 > a3){
if (a2>a4) {
if (a2 > a5) {
cout << a2 << " is maximum";
}
}
}
else if (a3 > a4){
if (a3>a5) {
cout << a3 << " is maximum";
}
}
else if (a4 > a5){
cout << a4 << " is maximum";
}
else{
cout<< a5 <<" is maximum ";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment