Re: Calendar Program



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
.



Relevant Pages

  • Re: Whats the best language to learn...
    ... over the arrays of vertices, ... loop over the selected models; ... recently my edge construction and shadow-volume rendering code ... but enums just make it easier and quicker to make ...
    (comp.programming)
  • Re: GNAT compiler switches and optimization
    ... allocating and freeing arrays, the the effects ... But I imagined allocation is just what is happening all the time ... type LIST is array of BOOLEAN; ... 2000 loop ...
    (comp.lang.ada)
  • Re: Non-rectangular 3D plot
    ... Ok I see where my code would get very confusing now. ... I originally had it accepting arrays for my inputs, ... I have shown my new code below without x and y in the for loop. ... to have y increment over a counter j for a given x value. ...
    (comp.soft-sys.matlab)
  • HHow can we Speed Up This Wend/While Loop
    ... I need some assistance to speed up a while / wend loop which I have ... The purpose of the loop is to populate two single dimension ... The recordset is made up of two columns, ... The two arrays on the other hand are called strLabel and curData, ...
    (comp.lang.basic.visual.misc)
  • RE: Fastest Selection
    ... Just loop through the arrays until a match is found and use the key's index ... Both are very fast but the Instr method typically is 20% faster. ... Dim sStr as String ...
    (microsoft.public.vb.general.discussion)