C Language

June 6, 2023

How to use switch control statement in C Language

Program to use switch control statement in C Language


#include<stdio.h>
int main()
{
    int choice;
    printf("Enter your choice : ");
    scanf("%d",&choice);
    switch(choice)
    {
        case 1:
        {
            printf("first\n");
            break;
        }
        case 2:
        {
            printf("second\n");
            break;
        }
        case 3:
        {
            printf("third\n");
            break;
        }
        default:
        {
            printf("woring choice\n");
        }
    }
    return 0;
}  

Output


Enter your choice : 3
third

by : Nadeem Khan

Quick Summary:

Program to use switch control statement in C Language copy #include<stdio.h> int main() { int choice; printf(“Enter your choice : “); scanf(“%d”,&choice); switch(choice) { case 1: { printf(“first\n”); break; } case 2: { printf(“second\n”); break; } case 3: { printf(“third\n”); break; } default: { printf(“woring choice\n”); } } return 0; } Output Enter your choice […]