Thread: a calendar c prog

  1. #1
    Registered User
    Join Date
    May 2009
    Posts
    7

    Lightbulb a calendar c prog

    Problem output should be:

    1st screen:
    Enter Month : 4
    Enter days : 30
    First day of the Month : 4

    2nd screen:
    April
    SMTWTFS
    .......1234
    567891011


    the calendar should start on wednesday due inputted firstday is 4.


    heres my code: i cant come up with the proper calendar output....
    any replies is a big help.. thank you..
    Code:
    #include<stdio.h>
    #include<conio.h>
    
    main()
    {
    clrscr();
    
    printf("Input Month Number     : ");
    scanf("%d",&month);
    printf("Number of days         : ");
    scanf("%d",&days);
    printf("First day of the month : ");
    scanf("%d",&firstday);
    clrscr();
    
    switch(month)
    {
     case 1: printf("\tJanuary\n\n");break;
     case 2: printf("\tFebruary\n\n");break;
     case 3: printf("\tMarch\n\n");break;
     case 4: printf("\tApril\n\n");break;
     case 5: printf("\tMay\n\n");break;
     case 6: printf("\tJune\n\n");break;
     case 7: printf("\tJuly\n\n");break;
     case 8: printf("\tAugust\n\n");break;
     case 9: printf("\tSeptember\n\n");break;
     case 10: printf("\tOctober\n\n");break;
     case 11: printf("\tNovemer\n\n");break;
     case 12: printf("\tDecember\n\n");break;
    }
    
    
    gotoxy(11,3);
     textcolor(12);
     cprintf("S");
    gotoxy(21,3);
     printf("M");
    gotoxy(31,3);
     printf("T");
    gotoxy(41,3);
     printf("W");
    gotoxy(51,3);
     printf("T  ");
    gotoxy(61,3);
     printf("F");
    gotoxy(71,3);
     printf("S");
     printf("\n");
    
    switch(firstday)
    {
     case 1:gotoxy(11,5);y=11;break;
     case 2:gotoxy(21,5);y=11;break;
     case 3:gotoxy(31,5);y=11;break;
     case 4:gotoxy(41,5);y=11;break;
     case 5:gotoxy(51,5);y=11;break;
     case 6:gotoxy(61,5);y=11;break;
     case 7:gotoxy(71,5);y=11;break;
    } 
    
    w=8-firstday;
    for(x=1;x<=days;x++)
     {
      if(x<=w){
       printf("%d",x);
       y=y+10;
       gotoxy(y,z);
              }
     }
    
    getch();
    return 0;
    }
    Last edited by nhoda911; 05-13-2009 at 11:34 PM.

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    You should add the part where you calculate the day of the specified month. Oh, and some indentation. Oh, and you should remove all that extra gotoxy/clearscr crap so people that want to help don't have to dig out their old DOS compilers.


    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    Registered User
    Join Date
    May 2009
    Posts
    7
    the number of days is inputted by the user, the month, and the first day of the month..

  4. #4
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Code:
    char *days[7] = { "Mon", "Tues", "Wednes", "Thurs", "Fri", "Satur" "Sun" };
    printf( "Day %d of the month of %s is %sday.\n", day, monthstring, days[ (number+start) % 7 ] );
    Something like that should be fine.


    Quzah.
    Hope is the first step on the road to disappointment.

  5. #5
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    > what should i add in my program?
    Indentation.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  6. #6
    Registered User
    Join Date
    May 2009
    Posts
    7
    ok.. thanks ill edit it sorry..

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Writing a program to make a calendar
    By Northstar in forum C Programming
    Replies: 17
    Last Post: 11-07-2007, 11:34 AM
  2. how to convert from solar calendar to lunar calendar??
    By zaracattle in forum C++ Programming
    Replies: 7
    Last Post: 11-30-2006, 07:17 AM
  3. writing a calendar program help please!!!
    By Newbie2006 in forum C Programming
    Replies: 7
    Last Post: 11-20-2002, 07:36 PM
  4. Try my prog...
    By Commander in forum A Brief History of Cprogramming.com
    Replies: 0
    Last Post: 05-09-2002, 07:43 AM