Write a Program in C to calculate or find the day on 1st january of any year
Write a Program in C to calculate or find the day on 1st january of any year?
According to the gregorian, it was Monday on the date 01/01/01. If any year is input through the keyboard write a program to find out what is the day on first january of this year.
#include “stdio.h”
#include “conio.h”
void main()
{
int leapdays,firstday,yr;
long int normaldays,totaldays;
clrscr();
printf(“Enter year “);
scanf(“%d”,&yr;);
normaldays=(yr-1)*365L;
leapdays=(yr-1)/4-(yr-1)/100+(yr-1)/400;
totaldays=normaldays+leapdays;
firstday=totaldays%7;
if(firstday==0) printf(“nMonday”);
if(firstday==1) printf(“Tuesday”);
if(firstday==2) printf(“nWednesday”);
if(firstday==3) printf(“nThrusday”);
if(firstday==4) printf(“nFriday”);
if(firstday==5) printf(“nSaturday”);
if(firstday==6) printf(“nSunday”);
printf(“nnnnnPress any key to exit….”);
getch();
}
#include “conio.h”
void main()
{
int leapdays,firstday,yr;
long int normaldays,totaldays;
clrscr();
printf(“Enter year “);
scanf(“%d”,&yr;);
normaldays=(yr-1)*365L;
leapdays=(yr-1)/4-(yr-1)/100+(yr-1)/400;
totaldays=normaldays+leapdays;
firstday=totaldays%7;
if(firstday==0) printf(“nMonday”);
if(firstday==1) printf(“Tuesday”);
if(firstday==2) printf(“nWednesday”);
if(firstday==3) printf(“nThrusday”);
if(firstday==4) printf(“nFriday”);
if(firstday==5) printf(“nSaturday”);
if(firstday==6) printf(“nSunday”);
printf(“nnnnnPress any key to exit….”);
getch();
}