switch case

 #include <stdio.h>

int main()
{
    int rank;
    printf("enter u r rank in 12 class:");
    scanf("%d",&rank);
    switch(rank) // only int and characters are valid here in ( )
    {
        case 1: //here "1,2,3" is not counting this is value of variable rank
        printf("u won car as a gift");
        break;

        case 2:
        printf("u won scooty as a gift");
        break;

        case 3:
        printf("u won cycle as a gift");
        break;

        default: //this will execute always unless u break the switch
        printf("this will execute when all cses are false");
    }
    return 0;
}

Comments

Popular posts from this blog

Tokens in C

Steps taken by a compiler to execute a C program

Variables and Data Types in C