![]() |
School of Engineering and
Applied
Science Department of Computer Science CSci 49 -- Introduction to C Computing http://www.seas.gwu.edu/~csci49/spring06 Prof. Michael B. Feldman mfeldman@gwu.edu |
Copy programs49/DateOps.c and programs49/DayTest.c.
Type ccheck DateOps.c.
This runs the checking part of the compilation, but does not generate
an executable file. (If you use ccompile
instead, you'll get a link error because there is no main to link it with.)
Now compile DayTest.c as
usual. The #include
in that program causes DateOps
to be linked in.
Now run DayTest. You'll notice that DayTest displays a number from 0 to 6. In this lab you will write two versions of DayTest (DayTestIf.c and DayTestSwitch.c). In DayTestIf.c, rewrite DayTest.c so that it displays the string representing the day (e.g. "Monday") instead of the number (i.e. 1). Solve the problem using if statements. In DayTestSwitch.c, do the same thing, but this time use switch instead of if.
Notice that you have now solved part of your problem for the next project. You should be able to take the ideas you worked out in this lab and apply them to your own project code.
Print out copies of DayTestIf.c and DayTestSwitch.c
and staple them to this lab handout for reference.
Examine the code for DateOps.
You'll see there are "stubs" for the functions required by Project 7.
Fill in the stub for daysInMonth.
(end of lab)