Tuesday, 14 February 2012

c program that accept year and print its day on 1st jan

#include<stdio.h>
#include<conio.h>
void main()
{int a,y,x;
printf("enter any year");
scanf("%d", &y);
a=y/4*5+y%4;
x=a%7;
if(y%4==0)
{x=x-1;
}
switch(x)
{
case 1:
printf("Sunday");
break;
case 2:
printf("Monday");
break;
case 3:
printf("Tuseday");
break;
case 4:
printf("Wednessday");
break;
case 5:
printf("Thrusday");
break;
case 6:
printf("Friday");
break;
default:
printf("Saturday");
}
getch();
}

No comments:

Post a comment