CS 159 EXAM #2 QUESTIONS AND
ANSWERS 2025
An infinite loop is a logical error - correct answer- True
The only way to stop a program caught in an infinite loop is to
shut down your terminal software - correct answer- False
A nested loop is a repetitive process contained inside of
another repetitive process - correct answer- True
One approach to potentially make solving problems that require
nested loops easier is to separate each repetitive process into
its own function - correct answer- True
According to the course standards a for loop should only be
used with counter-controlled processes - correct answer- True
According to the course standards if all three expressions are
not needed in a for loop then you should instead make use of a
while loop for your pretest looping needs - correct answer- True
, 2 | Page
All while loops can be converted into for loops that abide by
course standards - correct answer- False
You can make of x++, x+=1, and x =x+1, interchangeably as
the update (third) expression for a for loop to increment the
loop control variable - correct answer- True
The gcc compiler as used on the guru.itap.purdue.edu server
this semester will permit a variable to be declared and
initialized in the first expression of a for loop - correct answer-
False
The update expression of a for loop may only make user of the
addition or subtraction operator (includes ++, --, +=, =+, +, -) -
correct answer- False
This for loop will iterate 10 times: for(i=0; i!=0; i/=10) - correct
answer- True
This for loop will iterate 5 times: for(i=12345; i!=0; i/=10) -
correct answer- True