How to put all questions in one program by using switch statement?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Ahmed Adnan
    New Member
    • Mar 2013
    • 1

    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!
    Last edited by acoder; Mar 23 '13, 12:03 PM.
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    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

    Working...