Ad Code

Responsive Advertisement

switch case of c language.

First we understood that why switch case is used:

in simple example in our house there are many power switches if we want that only the fan is on than we on the fan button.

There are many button(condition) but we want that only fan is on. So,the switch case is same as a our power boards.

Switch case is work as same a power board.
The switch is the button and case is the part of task that perform.

Example :

 #include<stdio.h>
void main()
 { 
        Int a; 
        printf("Enter a number");
        scanf("%d", & a) ;

    switch (a)
   { 
        case 1:
           {
                  printf("today is Sunday ") ;br />            } break;   
       case 2:
          {
                  printf("today is Monday ") ;
          } break;
      case 3:
         {
                 printf("today is Tuesday ") ;
         } break;
      case 4:
        {
                printf("today is Wednesday ") ;
        } break;
     case 5:
       {
               printf("today is thursday ") ;
       } break;
     case 6:
      {
              printf("today is Friday ") ;
      } break;
     case 7:
      {
            printf("today is Saturday ") ;
      } break;
   }
 }

 Out put :Enter a number 2
                today is Monday.





❮ Previous                                                      Next ❯

Post a Comment

0 Comments