Skip to content

Instantly share code, notes, and snippets.

@gcs-abdulwahab
Last active September 23, 2022 06:03
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gcs-abdulwahab/1857c359835bb428bed54e2b9ec60e87 to your computer and use it in GitHub Desktop.
Save gcs-abdulwahab/1857c359835bb428bed54e2b9ec60e87 to your computer and use it in GitHub Desktop.
Finding the Maxmimu using only if statement
#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