Advertisement
Haval1

Question 1

Jan 17th, 2019
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.88 KB | None | 0 0
  1. // sol-final-ex1.cpp : Defines the entry point for the console application.
  2. /*find the max between 3 num entered by user
  3. Print A or B or F depending max value
  4. print A if 90>= max <=100
  5. print B if 80>= max <90
  6. print F if max < 80
  7. */
  8.  
  9. #include "stdafx.h"
  10. #include "iostream"
  11. using namespace std;
  12.  
  13. int main()
  14. {
  15.     int a, b, f,max=0;
  16.     cout << "\tEnter Three Number\n";
  17.     cout << "Num 1 : ";
  18.     cin >> a;
  19.     cout << "Num 2 : ";
  20.     cin >> b;
  21.     cout << "Num 3 : ";
  22.     cin >> f;
  23.     max = a;
  24.     if (max > b && max > f)
  25.         max = a;
  26.     else if (b > max && b > f)
  27.         max = b;
  28.     else if (f > max&&f > b)
  29.         max = f;
  30.     cout << "\nmax : " << max << endl;
  31.     if (max <= 100 && max >= 90)
  32.         cout << "Num 1 : " << a << endl;
  33.     else if (max < 90 && max >= 80)
  34.         cout << "Num 2 : " << b << endl;
  35.     else if (max < 80)
  36.         cout << "Num 3 : " << f << endl;
  37.     else
  38.         cout << "Number out of range\n";
  39.     return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement