lokhun

Untitled

Jan 21st, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.89 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     int x{0};
  8.     int y{0};
  9.     int z{0};
  10.     int sum{0};
  11.     int average{0};
  12.     int product{0};
  13.     int smallest{0};
  14.     int largest{0};
  15.  
  16.     cout << "Input three different integers: ";
  17.     cin >> x >> y >> z;
  18.     sum = x + y + z;
  19.     average = (x + y + z)/3;
  20.     product = x* y * z;
  21.  
  22.     cout << "Sum is " << sum << endl;
  23.     cout << "Average is " << average << endl;
  24.     cout << "Product is " << product << endl;
  25.  
  26.     largest = x;
  27.     smallest = x;
  28.  
  29.     if (largest < x)
  30.     largest = x;
  31.  
  32.     if (largest < y)
  33.     largest = y;
  34.  
  35.     if (largest < z)
  36.     largest = z;
  37.  
  38.     if (smallest > x)
  39.     smallest = x;
  40.  
  41.     if (smallest > y)
  42.     smallest = y;
  43.  
  44.     if (smallest > z)
  45.     smallest = z;
  46.  
  47.     cout << "Smallest is " << smallest << endl;
  48.     cout << "Largest is " << largest << endl;
  49.  
  50.     return 0;
  51. }
Advertisement
Add Comment
Please, Sign In to add comment