Can anyone tell me what's wrong here? The code will run but it won't 
read the switch case statement in my first switch case statement.

/* This code will guide you through your own adventure where you can 
choose to be a gangster, a knight, or Chuck Norris.

The ALGORITHM for the ENTIRE code is:
Welcome Message
ask/get answer from 3 options to choose from
switch answer
    case 'g'
         print hello (gangster)
    case 'k'
         print hello (knight)
    case 'c'
         print hello (Chuck Norris)
    default 
        error
*/

#include <stdio.h>
#include <stdlib.h>

int main(void)
{
    //declare variable
    char menu = 'g' || 'k' || 'c';
    char gmenu = 'a' || 'b';
    
        //Welcome Message
        printf("Welcome to choose your own adventure.\n\n"
        "You can choose between an adventure as a gangster, a knight, 
or "
        "Chuck Norris.\n\n"
        "Please enter \"g\" for Gangster, \"k\" for Knight, and \"c\" 
for "
        "Chuck Norris.\n"
        "Choose from one of the following: \n"
                    "1.\tGangster\n"
                    "2.\tKnight\n"
                    "3.\tChuck Norris\n\n");
            scanf("%c",&menu);
        
            //switch depending on answer
            switch (menu)
            {
                case 'g':
                    printf("You are a hardcore ganster from the 
streets "
                    "of Compton. You just got out of jailand you 
came "
                    "back to your hood only to find out that it had 
been "
                    "taken over by arival gang.\n"
                    "Would you rather\n"
                    "a: Join the rival gang\n"
                    "or\n"
                    "b: Get some guys together to take your hood 
back\n");
                    break;
                    
                          scanf("%c", &gmenu);
                          switch (gmenu)
                          {
                                 case 'a':
                                      printf("You've selected a.\n");
                                      break;
                                 case 'b':
                                      printf("You've selected b.\n");
                                      break;
                          }
                          
                case 'k':
                    printf("You are a holy knight who just passed 
training."
                    " Now you need to get some quests under your belt 
if "
                    "you want to be respected as a knight. You go 
into town"
                    " to\n"
                    "find some quests and you encounter two people.\n"
                    "Would you rather\n"
                    "a: Go deep into a mine to find hidden treasure\n"
                    "or\n"
                    "b: Rescue a beautiful maiden\n");
                    break;
        
                case 'c':
                    printf("You are Chuck Norris. Men worship you and 
women "
                    "can't resist you.\n"
                    "You are considered by all as a God.\n"
                    "The game is over. You win!\n\n");
                    break;
                //Error
                default :
                    printf("Error, that option is not valid.\n\n");
                    break;
           }
       
    system("pause");
    return(0);
}


Reply via email to