Home

A program to explain SWITCH-CASE-DEFAULT, without using break

C Programming Language 022

The following code shows how to write a program to explain SWITCH-CASE-DEFAULT, without using break. Read an integer value between 1 to 5 and print it in words.

Program

#include <stdio.h>

void main()
{
    int ch;
    printf("Enter a number: ");
    scanf("%d", &ch);

    switch (ch)
    {
    case 1:
        printf("ONE");
    case 2:
        printf("TWO");
    case 3:
        printf("THREE");
    case 4:
        printf("FOUR");
    case 5:
        printf("FIVE");
    }

    printf("\n");
}

Result

Enter a number: 4
FOURFIVE


Last Updated on

Next Post: Rules vs Guidelines →

Comments