Thread: writing a calendar program help please!!!

  1. #1
    Registered User
    Join Date
    Nov 2002
    Posts
    2

    Question writing a calendar program help please!!!

    Hello,
    I'm new in the world of C programming, and i'm taking an Into level computer science course, but the recent program we have to write up has gone completely over my head. The program is asking the user to enter a year, and then the program will print out a calendar to the screen of that year showing all 12 months on the correct days of the week and accounting for leap year, all based on Gregorian calendar starting from 1776. WOW!!!! can anyone help me out???

    Thanks

    Newbie...

  2. #2
    Registered User
    Join Date
    Nov 2002
    Posts
    491
    The hardest part of this is probably going to be creating output that looks good. You should probably just do a google search for an algorithm to find a calender based on the year, and then just follow that algorithm and print out the dates. I find that many people see a project and get tripped up on the programming aspect and make the problem more difficult than it actually is. Try to approach this as you would any problem in life: examine it, look for solutions, choose the best solution, and apply the solution. Programming is the last thing you need to worry about. Work some ideas out on paper first and then maybe play around with some C code and slowly get a working model going.

    Good luck

  3. #3
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    Do a search for zeller's algorithm.
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

  4. #4
    Registered User
    Join Date
    Nov 2002
    Posts
    157
    i think the easiest thing would have the program read from a significant file which has information on what years are leap, months days', and all data such as that. that way it would be more organized.

  5. #5
    Registered User
    Join Date
    Nov 2002
    Posts
    2

    calendar program

    is this a good start to a month????

    #include <stdio.h>

    main()
    { int day;

    int daysInMonth = 31;

    printf("\n S M T W R F S\n\n");

    for(day=1;day<=daysInMonth;day++)
    { printf("%4d", day);
    if(day%7==0)
    { printf("\n");
    }
    }

    printf("\n\n");
    }

  6. #6
    Green Member Cshot's Avatar
    Join Date
    Jun 2002
    Posts
    892
    Make sure you get your leap years right too
    Try not.
    Do or do not.
    There is no try.

    - Master Yoda

  7. #7
    Registered User
    Join Date
    Nov 2002
    Posts
    157
    that's why it would probably be easier to use a text file. there's a lot of changing data as far as time goes. it's not very constant.

  8. #8
    Registered User
    Join Date
    Nov 2002
    Posts
    491
    Originally posted by stallion
    that's why it would probably be easier to use a text file. there's a lot of changing data as far as time goes. it's not very constant.
    It's all pretty constant actually. Some guy on the internet has a thing so that you can calculate what day of the week any day of the year will be in any year in your head. The hardest part in this program is most likely coming up with a decent output format. It should be relativly painless to find and implement some algorithm to get what a year looks like.

    Technically speaking all you need is to find out what day of the week the year started on and if it is a leap year or not and then do a loop printing stuff out.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need some help with C program writing
    By The_PC_Gamer in forum C Programming
    Replies: 9
    Last Post: 02-12-2008, 09:12 PM
  2. Writing a C program for class....
    By Bizmark in forum C Programming
    Replies: 10
    Last Post: 11-13-2007, 10:31 AM
  3. Guidelines for writing optimal C program
    By Moony in forum C Programming
    Replies: 7
    Last Post: 06-30-2006, 08:08 PM
  4. Help with a file writing program
    By pritesh in forum C Programming
    Replies: 3
    Last Post: 11-11-2001, 01:56 AM
  5. writing a program called tail like the one in unix
    By fanaonc in forum C Programming
    Replies: 2
    Last Post: 11-04-2001, 02:20 AM