C++ Program which calculates the day of the week for any given date & month of the year 2002
#include<stdio.h>
#include<conio.h>
#include<iostream.h>
void main()
{
clrscr();
int opt,date,day;
char b;
cout<<"****A program to find out the day of the week for any date of the year 2002****\n\n";
cout<<"1.January\n2.February\n3.March\n4.April\n5.May\n6.June\n7.july\n8.August\n9.September\n10.October\n11.November\n12.December\n";
a: cout<<"\nEnter the value of the month:";
cin>>opt;
cout<<"\nEnter the date of the month:";
cin>>date;
switch(opt)
{
case 1: if(date<=31)
{day=(8+date)%7;}
else
cout<<"\nFor u'r kind information january has only 31 days.\n";
break;
case 2: if(date<=28)
{day=(11+date)%7;}
else
cout<<"\nFor u'r kind information february has only 28 days.\n";
break;
case 3: if(date<=31)
{day=(11+date)%7;}
else
cout<<"\nFor u'r kind information march has only 31 days.\n";
break;
case 4: if(date<=30)
{day=(7+date)%7;}
else
cout<<"\nFor u'r kind information april has only 30 days.\n";
break;
case 5: if(date<=31)
{day=(9+date)%7;}
else
cout<<"\nFor u'r kind information may has only 31 days.\n";
break;
case 6: if(date<=30)
{day=(12+date)%7;}
else
cout<<"\nFor u'r kind information june has only 30 days.\n";
break;
case 7: if(date<=31)
{day=(7+date)%7;}
else
cout<<"\nFor u'r kind information july has only 31 days.\n";
break;
case 8: if(date<=31)
{day=(10+date)%7;}
else
cout<<"\nFor u'r kind information august has only 31 days.\n";
break;
case 9: if(date<=30)
{day=(6+date)%7;}
else
cout<<"\nFor u'r kind information september has only 30 days.\n";
break;
case 10: if(date<=31)
{day=(8+date)%7;}
else
cout<<"\nFor u'r kind information october has only 31 days.\n";
break;
case 11: if(date<=30)
{day=(11+date)%7;}
else
cout<<"\nFor u'r kind information november has only 30 days.\n";
break;
case 12: if(date<=31)
{day=(6+date)%7;}
else
cout<<"\nFor u'r kind information december has only 31 days.\n";
break;
}
if(day==0)
{cout<<"\nIts SUNDAY.\n";}
if(day==1)
{cout<<"\nIts MONDAY.\n";}
if(day==2)
{cout<<"\nIts TUESDAY.\n";}
if(day==3)
{cout<<"\nIts WEDNESDAY.\n";}
if(day==4)
{cout<<"\nIts THURSDAY.\n";}
if(day==5)
{cout<<"\nIts FRIDAY.\n";}
if(day==6)
{cout<<"\nIts SATURDAY.\n";}
cout<<"\n****************************************************\n";
cout<<"\nWould u like to continue?[y/n]:";
cin>>b;
if(b=='y'||b== 'Y')
goto a;
else
getch();
}
Related Posts : C++ Programs
0 comments:
Post a Comment