An Example of a switch Statement
#include <iostream.h>
/************************************************************
File: switch.C
This program demonstrates the use of a switch statement
************************************************************/
int main()
{
int telephone_number;
cout << "Enter Extension Number: ";
cin >> telephone_number;
switch (telephone_number)
{
case 6279:
case 6127:{
cout << "This is on the 2nd floor of CCB" << endl;
break;
}
case 6520:{
cout << "This is on the 3rd floor of CCB" << endl;
break;
}
default: {
cout << "Invalid number \n";
break; //not required
}
}
return(0);
}
Back to Previous Page
Document:
Local Date:
Last Modified On: