===========================================================================
CODING
#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{
clrscr();
int a,c,d,e,f,g,h,i;
cout<<"\n Enter any year: ";
cin>>a;
c=a/4-475;
d=a-1900;
e=d-c;
i=a%4;
if(i==0)
{f=2*c-1;
g=e+f;
h=g%7;
if(h==0)
{cout<<"\n The First day of "<<a<<" is Monday";}
else if(h==1)
{cout<<"\n The First day of "<<a<<" is Tuesday";}
else if(h==2)
{cout<<"\n The First day of "<<a<<" is Wednesday";}
else if(h==3)
{cout<<"\n The First day of "<<a<<" is Thursday";}
else if(h==4)
{cout<<"\n The First day of "<<a<<" is Friday";}
else if(h==5)
{cout<<"\n The First day of "<<a<<" is Saturday";}
else if(h==6)
{cout<<"\n The First day of "<<a<<" is Sunday";}
}
else
{
f=2*c;
g=e+f;
h=g%7;
if(h==0)
{cout<<"\n The First day of "<<a<<" is Monday";}
else if(h==1)
{cout<<"\n The First day of "<<a<<" is Tuesday";}
else if(h==2)
{cout<<"\n The First day of "<<a<<" is Wednesday";}
else if(h==3)
{cout<<"\n The First day of "<<a<<" is Thursday";}
else if(h==4)
{cout<<"\n The First day of "<<a<<" is Friday";}
else if(h==5)
{cout<<"\n The First day of "<<a<<" is Saturday";}
else if(h==6)
{cout<<"\n The First day of "<<a<<" is Sunday";}
}
getch();
}
CODING
#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{
clrscr();
int a,c,d,e,f,g,h,i;
cout<<"\n Enter any year: ";
cin>>a;
c=a/4-475;
d=a-1900;
e=d-c;
i=a%4;
if(i==0)
{f=2*c-1;
g=e+f;
h=g%7;
if(h==0)
{cout<<"\n The First day of "<<a<<" is Monday";}
else if(h==1)
{cout<<"\n The First day of "<<a<<" is Tuesday";}
else if(h==2)
{cout<<"\n The First day of "<<a<<" is Wednesday";}
else if(h==3)
{cout<<"\n The First day of "<<a<<" is Thursday";}
else if(h==4)
{cout<<"\n The First day of "<<a<<" is Friday";}
else if(h==5)
{cout<<"\n The First day of "<<a<<" is Saturday";}
else if(h==6)
{cout<<"\n The First day of "<<a<<" is Sunday";}
}
else
{
f=2*c;
g=e+f;
h=g%7;
if(h==0)
{cout<<"\n The First day of "<<a<<" is Monday";}
else if(h==1)
{cout<<"\n The First day of "<<a<<" is Tuesday";}
else if(h==2)
{cout<<"\n The First day of "<<a<<" is Wednesday";}
else if(h==3)
{cout<<"\n The First day of "<<a<<" is Thursday";}
else if(h==4)
{cout<<"\n The First day of "<<a<<" is Friday";}
else if(h==5)
{cout<<"\n The First day of "<<a<<" is Saturday";}
else if(h==6)
{cout<<"\n The First day of "<<a<<" is Sunday";}
}
getch();
}
===========================================================================
No comments:
Post a Comment