Gargit

Conditional Statements Exercises Part 4

Jul 30th, 2016
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.39 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. void main()
  4. {
  5.     int choice = 0;
  6.  
  7.     std::cout << "enter a number from 1-4: ";
  8.     std::cin >> choice;
  9.  
  10.     switch (choice)
  11.     {
  12.         case 1:
  13.             std::cout << "1";
  14.             break;
  15.         case 2:
  16.         case 3:
  17.             std::cout << "2 or 3";
  18.             break;
  19.         case 4:
  20.             std::cout << "4";
  21.             break;
  22.         default:
  23.             std::cout << "Invalid";
  24.                 break;
  25.     }
  26.  
  27.     std::cout << std::endl;
  28.  
  29.     system("pause");
  30. }
Advertisement
Add Comment
Please, Sign In to add comment