# writing a calendar program help please!!!

• 11-19-2002
Newbie2006
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...
• 11-20-2002
orbitz
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
• 11-20-2002
Stoned_Coder
Do a search for zeller's algorithm.
• 11-20-2002
stallion
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.
• 11-20-2002
Newbie2006
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");
}
• 11-20-2002
Cshot
Make sure you get your leap years right too ;)
• 11-20-2002
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.
• 11-20-2002
orbitz
Quote:

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.