Last active
September 23, 2022 06:03
-
-
Save gcs-abdulwahab/1857c359835bb428bed54e2b9ec60e87 to your computer and use it in GitHub Desktop.
Finding the Maxmimu using only if statement
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
int main() { | |
int a1 = 1 ; | |
int a2 = 1 ; | |
int a3 = 1 ; | |
int a4 = 1 ; | |
int a5 = 1 ; | |
/* | |
if (a1>a2) | |
if (a1>a3) | |
if (a1>a4) | |
if(a1>a5) | |
cout<<a1<< " is maximum"; | |
*/ | |
if (a1 >= a2 && a1 >= a3 && a1>= a4 && a1 >= a5) | |
cout<< a1 <<" is the maximum "; | |
if (a2 >= a1 && a2 > a3 && a2> a4 && a2 > a5) | |
cout<< a2 <<" is the maximum "; | |
if (a3 > a1 && a2 > a3 && a2> a4 && a2 > a5) | |
cout<< a2 <<" is the maximum "; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment