Aim – WAP To Find The First Day of the Year
Code -
#include<stdio.h>
#include<conio.h>
void main()
{
int year, leapdays, days;
clrscr ();
printf ("Enter The Year To Find First Day (Year>1900) : ");
scanf ("%d", &year);
leapdays=(year-1900)/4;
days=leapdays+(year-1900);
days=days%7;
switch (days)
{ case 0:printf ("Monday\n");
break;
case 1:printf ("Tuesday\n");
break;
case 2:printf ("Wednesday\n");
break;
case 3:printf ("Thursday\n");
break;
case 4:printf ("Friday\n");
break;
case 5:printf ("Saturday\n");
break;
case 6:printf ("Sunday\n");
break;
}
getch ();
}
OUTPUT
Enter The Year To Find First Day (Year>1900): 2015
Thursday
No comments:
Post a Comment