WAP to input week number and print week day name.



C program to input number of week's day(1-7) and translate to its equivalent name of the day of the week

You will learn to calculate the week day name by using switch case in this example.


#include<stdio.h>
#include<conio.h>
void main()
{
int ch;
clrscr(); //to clear the screen
printf(“Enter number of week’s day(1-7):”);
scanf(“%d”,&ch);

switch(ch)
{
case 1: printf(“nSunday”);
break;
case 2: printf(“nMonday”);
break;
case 3: printf(“nTuesday”);
break;
case 4: printf(“nWednesday”);
break;
case 5: printf(“nThursday”);
break;
case 6: printf(“nFriday”);
break;
case 7: printf(“nSaturday”);
break;
}
getch(); //to stop the screen
}

Output:
Enter Number of Week Days(1-7): 6
Friday

Comments

Most Viewed

Write C program to enter any year and check whether year is leap year or not using conditional/ternary operator.

C Program to Find Third Angle of a Triangle