Monday, 10 October 2011

10-10-2011 switch statement


/*Just an example of usage of switch statement*/

#include <stdio.h>
#include <conio.h>
int main()
{
    int x;
   
    printf("Enter a number: ");
    scanf("%d", &x);
   
    switch(x)
    {
         case 1:
              printf("good");
              break;
         case 2:
              printf("fair");
              break;
         default:
              printf("bad");
              break;
    }
   
    getche();
    return 0;
}

No comments:

Post a Comment