nesting of switch in c language

 

#include<stdio.h>
int main()
{
    int num;
    char ch;
    printf("enter the number \n");
    scanf("%d", &num);
    switch (num)
    {
    case 1:printf("enter the character\n");
           scanf("%c", &ch);
           scanf("%c", &ch);
           switch (ch)
           {
           case 'R':
               printf("RED");
               break;
           case 'B':
               printf("BLUE");
               break;
           
           default:printf("wrong character");
               break;
           }
        
        break;
    
    case 2:printf("enter the character\n");
           scanf("%c", &ch);
           scanf("%c", &ch);
           switch (ch)
           {
           case 'R':
               printf("RAT");
               break;
           case 'B':
               printf("BAT");
               break;
           
           default:printf("wrong character");
               break;
           }

        break;
    default:printf("entered numbre is wrong");
    
   
        break;
    }

   return 0;
}

Comments

Popular posts from this blog

priority_queue

css in phone