Write a program in C to read any day number in integer and display day name in the word

 

#include <stdio.h>

#include <conio.h>

void main()

{

    char a;

    printf("enter any digit(1-7) to print a names of days: ");

    scanf("%c", &a);

    switch (a)

    {

    case '1':

        printf("Sunday!");

        break;

    case '2':

        printf("Monday!");

        break;

    case '3':

        printf("Tuesday!");

        break;

    case '4':

        printf("Wednesday!");

        break;

    case '5':

        printf("Thursday!");

        break;

    case '6':

        printf("Friday!");

        break;

    case '7':

        printf("Saturday!");

        break;

    default:

        printf("enter a number from 1-7");
    }

    getch();
}

 

 OUTPUT

Enter any digit(1-7) to print names of days: 5

Thursday!


Follow our page for regular updates.

0 Comments