Switch Case C - Switch Case Program in C



 Switch Case Program in C

Learn c - c tutorial - Switch Case Program in C - c examples - c programs

Switch Case Program in C

  • Substitute for long if statements that compare a variable to several "integral" values and the basic format for using switch case is printed is called as Switch case statements.
  • The value of the variable given into switch is compared to the value following each of the cases, and once value matches the value of the variable, the computer continues executing the program from that point.

Sample Code

#include <stdio.h>
int main()
{
    int a=2;
    switch(a)
    {
    case 1:
        printf("One\n");
        break;
    case 2:
        printf("Two\n");
        break;
    default:
        printf("Default\n");
    }
    return 0;
}

Output

Two


View More Quick Examples


Related Searches to Switch Case C - Switch Case Program in C