COM 1100 Foundations of Computer Science

Quiz 4 -- Tuesday, November 14th

Fall 2000 -- Professor Futrelle
College of Computer Science, Northeastern U., Boston, MA

THIS IS AN OPEN-BOOK QUIZ -- TEXTBOOK ONLY (FRIEDMAN AND KOFFMAN)

This is a red quiz. The people to your left and right should have a blue quiz.

 

Print your name here____________________________________________________ ID#___________________

Please write your answers on the this sheet, and print your name and ID number above. This quiz covers iteration beyond Sec. 5.5 and basic file I/O operations from Secs. 8.1 and 8.2.

Question 1.
    In Fig. 5.9, page 260, replace the assignment statement for digitRead in the while loop with an if statement that assigns the value of true or false to digitRead. (You don't have to copy the entire code in 5.9 into your answer, just the relevant few lines.)

Question 2.
    Let x be type float, n type int, and c type char. Indicate the contents of each variable after each read operation performed on the input stream:

931 4 11.4 UB*<nwln>67 G <nwln>

where "<nwln>" means that a newline is enter (also known as '\n'). Assume that the input buffer is reset to the first character before the start of questions 2A and 2B below. (HINT: You may want to check pg. 719.)

    2A. cin >> n; cin.get(c);

    2B. cin >> c >> n >> x; cin >> c;