Advertisement
Felanpro

determine largest number of 4 values!

Oct 18th, 2017
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.50 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int _max(int x1, int x2)
  6. {
  7.     if(x1 > x2)
  8.         return x1;
  9.     else
  10.         return x2;
  11. }
  12.  
  13. int main()
  14. {
  15.     int a, b, c, d;
  16.  
  17.     cout << "insert the values: ";
  18.     cin >> a >> b >> c >> d;
  19.  
  20.     int comparison;
  21.     int second_comparison;
  22.     int last_comparison;
  23.  
  24.     comparison = _max(a, b);
  25.     second_comparison = _max(comparison, c);
  26.     last_comparison = _max(second_comparison, d);
  27.  
  28.     cout << last_comparison << "\n";
  29.  
  30.     return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement