CS 2401 Quiz #2

Date: Tuesday, September 1, 2010.

1. Scheduling classes is difficult, let us help. Let an array capacity[i] contain the number of students that can fit into the i-th classroom, and let name[i] contain the name of the i-th classroom (e.g., "COMP 308"). Write down a piece of code that, given the number of students in the class, finds the first classroom in the list that can fit that many students and prints the name of the classroom.










































2. Trace your code on an example of 3 Computer Science classrooms COMP 321, COMP 322, and COMP 308, with capacities 30, 30, and 50, and a class of size of 45.






































Turn over, please.

2. Please answer questions about the reading assignment:

2a. can an array be 2-dimensional?

2b. can an array be 3-dimensional?

2c. is it possible to have a 2-dimensional array with rows of different size?