Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 136,108 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,710 people online right now. Registration is fast and FREE... Join Now!




CALENDAR

 
Reply to this topicStart new topic

CALENDAR

naash
2 Oct, 2007 - 01:25 AM
Post #1

D.I.C Head
**

Joined: 25 Aug, 2007
Posts: 77


My Contributions

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();
}



User is offlineProfile CardPM
+Quote Post

William_Wilson
RE: CALENDAR
2 Oct, 2007 - 05:21 AM
Post #2

lost in compilation
Group Icon

Joined: 23 Dec, 2005
Posts: 3,984



Thanked: 16 times
Dream Kudos: 3275
Expert In: Java, C, Javascript

My Contributions
what result do you get, and what would you expect, please give us a couple of short example input/output.
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/1/08 09:23PM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month