{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Computer Science 61B - Spring 1996 - Clancy - Midterm 1

# Computer Science 61B - Spring 1996 - Clancy - Midterm 1 -...

This preview shows pages 1–3. Sign up to view the full content.

CS 61B, Midterm #1, Spring 1996 CS 61B, Spring 1996 Midterm #1 Professor M. Clancy Problem 0 (1 point, 1 minute) Put your login name on each page. Also make sure you have provided the information requested on the first page. Problem 1 (4 points, 10 minutes) A program to print a calender as in programmang assignment 2 includes the following code. for(int month=JAN; month<=DEC; month++) { PrintHeading (month, year); PrintDates (month, year); } The PrintDates function includes the following code. int firstDay = DayOfWeek (month, 1, year); for (int k=1; k<=firstDay; k++) { cout << " "; } for (int date=1; date<=NumDaysIn (month, year); date++) { cout << setw(3) << date; if (IsEndOfWeek (date, firstDay)) { cout << endl; } } Suppose that when the program is run, a calendar is printed in which every month starts on a Sunday as shown below. January 1996 S M T W T F S 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 file:///C|/Documents%20and%20Settings/Jason%20Raft...20Spring%201996%20-%20Clancy%20-%20Midterm%201.htm (1 of 6)1/27/2007 5:40:34 PM

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
CS 61B, Midterm #1, Spring 1996 22 23 24 25 26 27 28 29 30 31 February 1996 S M T W T F S 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 March 1996 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 ... Part a Which of the following functions is most likely to contain the bug? Circle the name of the probably buggy function below, and briefly describe a flaw in the function that could produce the incorrect output.
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 6

Computer Science 61B - Spring 1996 - Clancy - Midterm 1 -...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online