switch problems

Discussion in 'Programming' started by claude_tech, Jun 12, 2011.

  1. claude_tech

    claude_tech New Member

    Joined:
    Jun 12, 2011
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    Hi,
    i want to use two 'switch' in my code but it didn't work :
    Code:
    [COLOR=#339933]#include <stdio.h>[/COLOR]   [COLOR=#0000ff]char[/COLOR] choix1,choix2;   main() {   printf([COLOR=#ff0000]"ENTER UR CHOICE :[COLOR=#800000]\n[/COLOR]"[/COLOR]); choix1 = getchar();   [COLOR=#0000ff]switch[/COLOR] (choix1)   {   [COLOR=#0000ff]case[/COLOR][COLOR=#ff0000]'y'[/COLOR]: printf([COLOR=#ff0000]"ENTER THE FILE :[COLOR=#800000]\n[/COLOR]"[/COLOR]); choix2=getchar();   [COLOR=#0000ff]switch[/COLOR] (choix2) {     [COLOR=#0000ff]case[/COLOR][COLOR=#ff0000]'1'[/COLOR]:     printf([COLOR=#ff0000]"'.bas' file"[/COLOR]);     [COLOR=#0000ff]break[/COLOR];       [COLOR=#0000ff]case[/COLOR][COLOR=#ff0000]'2'[/COLOR]:     printf([COLOR=#ff0000]"'.900' file"[/COLOR]);     [COLOR=#0000ff]break[/COLOR];       [COLOR=#0000ff]default[/COLOR] : 	printf([COLOR=#ff0000]"WRONG CHOICE"[/COLOR]);     };   [COLOR=#0000ff]break[/COLOR];   [COLOR=#0000ff]case[/COLOR][COLOR=#ff0000]'n'[/COLOR]: printf([COLOR=#ff0000]"2"[/COLOR]); [COLOR=#0000ff]break[/COLOR];       [COLOR=#0000ff]default[/COLOR] : 	printf([COLOR=#ff0000]"WRONG CHOICE"[/COLOR]);   }; }
    help please
     
  2. claude_tech

    claude_tech New Member

    Joined:
    Jun 12, 2011
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    Code:
    #include <stdio.h>
     
    char choix1,choix2;
     
    main()
    {
     
    printf("ENTER UR CHOICE :\n");
    choix1 = getchar();
     
    switch (choix1)
     
    {
     
    case'y':
    printf("ENTER THE FILE :\n");
    choix2=getchar();
     
    switch (choix2)
    {
        case'1':
        printf("'.bas' file");
        break;
     
        case'2':
        printf("'.900' file");
        break;
     
        default :
    	printf("WRONG CHOICE");
     
     
    };
     
    break;
     
    case'n':
    printf("2");
    break;
     
        default :
    	printf("WRONG CHOICE");
     
    };
    }
    
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice