Program to find day of week
Program:
#include<stdio.h>
void main()
{
int wd;
printf("enter number of day from 1 to 7 starting from Sunday: ");
scanf("%d",&wd);
switch (wd)
{
case 1: printf("Sunday Holiday :) ");
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("Invalid entry");
}
}
Output:
Note:
We have used switch case here.
For syntax see Syntax in C
No comments:
Post a Comment