write a program which tells the day on 1st january of a year entered by the user. the year entered should be after 2001.

#include<stdio.h>
void main()
{
int year,i,count=0,sub;
printf("enter the year after 2001 for which u want the day");
scanf("%d",&year);
for(i=2001;i<year;i++)
{
if(((i%4==0)&&(i%100!=0))||(i%400==0))
{
    printf("leap year%d",i);
count=count+1;
}
}
printf("\nthe value of count is=%d\n",count);
sub=year-2001;
printf("%d",sub);
sub=sub+count;
printf("\nthe value of sub is=%d\n",sub);
for(sub;sub>7;sub=sub-7);
printf("\nthe value of sub is=%d\n",sub);
switch(sub)
{
case 1:
printf("tuesday");
break;
case 2:
printf("wednesday");
break;
case 3:
printf("thursday");
break;
case 4:
printf("friday");
break;
case 5:
printf("saturday");
break;
case 6:
printf("sunday");
break;
case 7:
printf("monday");
break;
}
}

NOTE-  i have compiled this program in codeblocks if u do it in turbo c++  use  conio.h  header file in the beginning  and getch()  a the  last.

No comments:

Post a Comment

Implemet Stack in python

  class Stack : def __init__ ( self , data ): self . stack = [] if ( data ): self . stack . append ( da...