Engr 101 - Exam 1_key F12

4 bool x false and false or true bool z

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: screen. ____ Iteration repeatedly executes code until its continuation condition is false. _X__ A pass- by- reference input variable gives a procedure a copy of the variable’s data from the caller. ____ Functions should not have side effects. b) What is the value of y after the following code executes? int x = 25; int y = 0; while(x >= 0) { x--; y++; } ____ 25 _X__ 26 ____ 0 ____ -1 ____ infinite loop; no result value c) A while loop: ____ can be used to read the contents of a file of arbitrary length ____ must modify some part of its continuation condition in its loop body to prevent an infinite loop ____ can be converted into a for loop _X__ All of the above ____ None of the above d) Which of the following lines of code will not compile? _X__ int v = 7 = 14; ____ double w = (7 – 3) / 3.4; ____ bool x = !(false) and false or true; ____ bool z = true == !false; e) A switch statement: ____ must have at least three cases _X__ repeatedly executes its cases unless it encounters a break statement ____ must always have a default case ____ All of the above _X__ None of the above This was supposed to be the answer, but the second option is acceptable ENGR 101: Intro to Computers & Programming - Fall 2012 Page 3 of 8 Uniqname: ____________________________ Question 3 – What are the outputs? (30 points) In the box provided below each of the small programs on this page and the next page, write only one of the following in order to indicate how the program performs (use scratch paper for any calculations): • The phrase “Does not compile” indicating the program never compiles. • The phrase “Infinite loop” indicating the program e...
View Full Document

Ask a homework question - tutors are online