Thread: a calendar c prog

Threaded View

Previous Post Previous Post   Next Post Next Post
  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.

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