Q) Develop a C++ program to print a calendar for one year, given the year and the day of the weak that January 1’st falls on. Make your program interactive.
The following code does not gimme the right answer . Plz help me rectify !
CODE
#include<iostream.h>
#include<conio.h>
#include<iomanip.h>
void main()
{
clrscr();
int start_day,day,i,j,num;
static int start_month[]={31,28,31,30,31,30,31,31,30,31,30,31};
day=start_day;
cout<<"\nEnter the 1st day of the year : ";
cin>>day;
for(i=0;i<12;i++)
{
num=i;
j=day;
switch(j)
{
case 0 : cout<<"\n JAN \n";
break;
case 1 : cout<<"\n FEB \n";
break;
case 2 : cout<<"\n MAR \n";
break;
case 3 : cout<<"\n APR \n";
break;
case 4 : cout<<"\n MAY \n";
break;
case 5 : cout<<"\n JUN \n";
break;
case 6 : cout<<"\n JUL \n";
break;
case 7 : cout<<"\n AUG \n";
break;
case 8 : cout<<"\n SEP \n";
break;
case 9 : cout<<"\n OCT \n";
break;
case 10 : cout<<"\n NOV \n";
break;
case 11 : cout<<"\n DEC \n";
break;
}
cout<<"\nSUN MON TUE WED THU FRI SAT\n";
for(int k=(j-1);k>0;k--)
cout<<" "<<" "<<" ";
while(num<=(start_month[i]))
{
cout<<setw(4)<<num;
num++;
j++;
if(j==7)
{
j=1;
cout<<"\n";
}
cout<<setw(4);
day=j;
}
}
getch();
}