Demonstrate SWITCH statement - C++ Statement

C++ examples for Statement:switch

Description

Demonstrate SWITCH statement

Demo Code

#include <iostream>
using namespace std;
int main()//w  w  w .j  a  v a2 s .  c  o m
{
   int speed;                        //turntable speed
   cout << "\nEnter 3, 4, or 5: ";
   cin >> speed;                     //user enters speed
   switch(speed)                     //selection based on speed
   {
      case 3:
      cout << "3\n";
      break;
      case 5:
      cout << "5\n";
      break;
      case 4:
      cout << "4\n";
      break;
   }
   return 0;
}

Result


Related Tutorials