Re: Calendar Program
- From: Ian Malone <ibm21@xxxxxxxxx>
- Date: Mon, 31 Oct 2005 12:23:08 +0000
tigrfire wrote:
I'm trying to write a program that will display the following output: MONTHLY CALENDAR
This program displays a calendar. You need to provide the day of the week on which January 1 falls, and indicate whether or not the year is a leap year.
Enter the code number for the day of the week on which January 1 falls: 0- Sun 1- Mon 2- Tue 3- Wed 4- Thu 5- Fri 6- Sat
Enter day code now (0 - 6): 4
Is the calendar for a leap year? (type 1 for yes, 0 for no): 0
As you said in another post you can't use functions or arrays. I'm not sure what the aim of the exercise is. Except maybe to force you to do it this way and then show you how it should be done.
Since what you basically have is one function to be called in a loop (does a month of a given number of days, starting from a specified day) it's possible to either call main recursively (more trouble than it's worth, especially given that you can't use arrays) or put the statements in a loop.
At which point the array restriction starts to bite. Of course an array is little more than an adjacent list of objects. You'll just have to consider how you might do; char *array[12], c; array[0] = "January"; array[1] = "February"; /* ... initialise rest of array[] and ii to something sensible */ c = array[ii]; without the convenience of [] doing the indexing for you.
(And finally, if you're not allowed to use arrays, are you allowed to use string literals?)
-- imalone .
- Prev by Date: Re: Simple question
- Next by Date: Re: Pse, help me to understand this code
- Previous by thread: Re: Calendar Program
- Next by thread: Re: Simple question
- Index(es):
Relevant Pages
|