Advertisement
Spocoman

05. Number 100...200

Sep 1st, 2023 (edited)
660
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.63 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6.     int number;
  7.     cin >> number;
  8.  
  9.     if (number < 100) {
  10.         cout << "Less than 100" << endl;;
  11.     }
  12.     else if (number <= 200) {
  13.         cout << "Between 100 and 200" << endl;;
  14.     }
  15.     else {
  16.         cout << "Greater than 200" << endl;
  17.     }
  18.    
  19.     return 0;
  20. }
  21.  
  22. Решение с тернарен оператор:
  23.  
  24. #include <iostream>
  25.  
  26. using namespace std;
  27.  
  28. int main() {
  29.     int number;
  30.     cin >> number;
  31.  
  32.     cout << (number < 100 ? "Less than 100" : number <= 200 ? "Between 100 and 200" : "Greater than 200") << endl;
  33.    
  34.     return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement