Advertisement
Nofxthepirate

Exercise 2.19

Jan 24th, 2018
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.28 KB | None | 0 0
  1. //Exercise 2.19
  2. //This program performs basic arithmetic, and comparison on three numbers
  3. #include <iostream>
  4. using namespace std;
  5.  
  6. int num1{}, num2{}, num3{};
  7.  
  8. int main(){
  9.     cout << "Input three different integers: " << endl;
  10.     cin >> num1 >> num2 >> num3;
  11.     cout << "Sum is " << num1 + num2 + num3 << endl;
  12.     cout << "Average is " << (num1 + num2 + num3) / 3 << endl;
  13.     cout << "Product is " << num1 * num2 * num3 << endl;
  14.  
  15.     if (num1 > num2 && num2 > num3){
  16.         cout << "Largest is " << num1 << endl;
  17.         cout << "Smallest is " << num3 << endl;
  18.     }
  19.     if (num1 > num3 && num3 > num2) {
  20.         cout << "Largest is " << num1 << endl;
  21.         cout << "Smallest is " << num2 << endl;
  22.     }
  23.     if (num2 > num1 && num1 > num3) {
  24.         cout << "Largest is " << num2 << endl;
  25.         cout << "Smallest is " << num3 << endl;
  26.     }
  27.     if (num2 > num3 && num3 > num1) {
  28.         cout << "Largest is " << num2 << endl;
  29.         cout << "Smallest is " << num1 << endl;
  30.     }
  31.     if (num3 > num2 && num2 > num1) {
  32.         cout << "Largest is " << num3 << endl;
  33.         cout << "Smallest is " << num1 << endl;
  34.     }
  35.     if (num3 > num1 && num1 > num2) {
  36.         cout << "Largest is " << num3 << endl;
  37.         cout << "Smallest is " << num2 << endl;
  38.     }
  39.  
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement