counter

Free Hit Counter

C program to display day on !st january of any year



Q:According to Gregorian calendar,it was monday on 01/01/1900.If any year is input through the keyboard.write a program to find out what was the date on 1st January of that year


#include
#include
void main()
{
long int nd,ld,td,fd,year;
clrscr();
printf("enter the year");
scanf("%ld",&year);
nd=(year-1)*365;
ld=(year-1)/4-(year-1)/100+(year-1)/400;
td=nd+ld;
fd=td%7;

if(fd==0)
printf("\n monday");
if(fd==1)
printf("\n tuesday");
if(fd==2)
printf("\n wednesday");
if(fd==3)
printf("\n thursday");
if(fd==4)
printf("\n friday");
if(fd==5)
printf("\n saturday");
if(fd==6)
printf("\n sunday");
getch();
}

2 comments:

Isuru Wijesinghe said...

please put comments. It will helpful to understand your source code.

Thanks...

Unknown said...

you should give meaning full names to your variables....that will help us to understand the programme....

Post a Comment