Multiple Alternatives. The Switch Statement

Place your mouse in the areas below to see comments about the corresponding sections of code  
Code
 
/*  Example on switch statement
    Jacob Y. Kazakia
    Spring 2001
 
Engineering 1 is usually taught in many sections
We try to get the best people to conduct the recitations. This program provides the name of your instructor when you give the number of the section ( 10, 11, 12, 13, 14, 15, 16, 17)
*/
 
#include <iostream.h>
main()
{
 
int section;
 
cout<<" \n\n  Who is your instructor?";
cout<<"\n  Enter your section number   >>> ";
cin>> section;
 
switch(section)
{
 
case 10:
case 11:
cout<<" \n Bob Hope"<< endl;
break ;
 
case 12:
case 13:
cout<<" \n Science Dreamer"<< endl;
break;
 
case 14:
case 15:
cout<<" \n He_thinks_too_much"<< endl;
break;
 
case 17:
case 18:
cout<<" \n John Knowall"<< endl;
break;
 
default:
cout<<"  \n  I hope you learn your section number soon";
 
}
 
cout<<" \n\n Have a nice day \n\n";
 
cout<<" enter e ( exit) to exit ....";
char hold;
cin>> hold;
 
}

(text file of the code)

(printable file)

© 2001 J.Y. Kazakia. All rights reserved