How to put all questions in one program by using switch statement?
How to put my all assignment questions that are 6 in number in one program by using switch statement ?
so if a user wants to see any question by choice!
The easiest way to do that is use a switch statement where each case represents a choice:
Code:
switch (choice)
{
case 1:
/* user has entered choice 1 */
put your logic here..,
break;
case 2:
/* user has entered choice 2 */
put your logic here..,
break;
etc...
default:
/* if no case applies you coe here
like a bad menu choice...
}
The choice must be an integer.
Usually, a switch like this is inside a loop where the user enters the choice.
Comment