Switch Case Example In C - Math Traders

Latest

Switch Case Example In C

                Switch Case Example in C


In this C question we will understand the use of switch case in the C that how we can use switch case in C with an example program.

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

int main()
{
    int num;
    printf("\n\tenter a number\n\t");
    scanf("%d",&num);
    switch(num)
    {
        case 1:
    printf("\n\tentered number is 1");
    break;
    case 2:
    printf("\n\tentered number is 2");
    break;
    default:
        printf("\n\tentered number is niether 1 or 2");
    }

    return 0;
}

No comments:

Post a Comment