csansoon

P4.06 P73231 Maximum of four integer numbers

Oct 24th, 2018
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.37 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int max4(int a, int b, int c, int d) {
  5.     int x;
  6.     if(a>=b&&a>=c&&a>=d) x=a;
  7.     else if (b>=a&&b>=c&&b>=d) x=b;
  8.     else if (c>=a&&c>=b&&c>=d) x=c;
  9.     else x=d;
  10.     return x;}
  11.    
  12. int main(){
  13.     int a,b,c,d;
  14.     cout<<"A=";
  15.     cin>>a;
  16.     cout<<"B=";
  17.     cin>>b;
  18.     cout<<"C=";
  19.     cin>>c;
  20.     cout<<"D=";
  21.     cin>>d;
  22.     cout<<endl<<max4(a,b,c,d)<<endl;
  23.    
  24.     }
Advertisement
Add Comment
Please, Sign In to add comment