CS 159 Exam #2
An infinite loop is a logical error - Answers-True
The only way to stop a program caught in an infinite loop is to shut down your terminal software -
Answers-False
A nested loop is a repetitive process contained inside of another repetitive process - Answers-True
One approach to potentially make solving problems that require nested loops easier is to separate each
repetitive process into its own function - Answers-True
According to the course standards a for loop should only be used with counter-controlled processes -
Answers-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 - Answers-True
All while loops can be converted into for loops that abide by course standards - Answers-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 - Answers-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 - Answers-False
, The update expression of a for loop may only make user of the addition or subtraction operator
(includes ++, --, +=, =+, +, -) - Answers-False
This for loop will iterate 10 times: for(i=0; i!=0; i/=10) - Answers-True
This for loop will iterate 5 times: for(i=12345; i!=0; i/=10) - Answers-True
This for loop will iterate 6 times: for(i=1; i<=32; i*2) - Answers-False
This short-circuit method of evaluating logical expressions does not apply to loop control expressions -
Answers-False
Control-forcing statements such as break, continue, and the use of multiple return statements in a user-
defined function are prohibited by course standards as mechanisms to terminate repetitive processes -
Answers-True
The condition in a recursive function when which the recursive function calls stop is known as the best
case - Answers-True
Recursion should not be user with event-controlled processes as the result may be more function calls
than the memory of the computer can handle - Answers-True
A large number of recursive function calls may result in a crash due to running out of memory - Answers-
True
An iterative solution is one that is implemented using a looping construct - Answers-True
An infinite loop is a logical error - Answers-True
The only way to stop a program caught in an infinite loop is to shut down your terminal software -
Answers-False
A nested loop is a repetitive process contained inside of another repetitive process - Answers-True
One approach to potentially make solving problems that require nested loops easier is to separate each
repetitive process into its own function - Answers-True
According to the course standards a for loop should only be used with counter-controlled processes -
Answers-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 - Answers-True
All while loops can be converted into for loops that abide by course standards - Answers-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 - Answers-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 - Answers-False
, The update expression of a for loop may only make user of the addition or subtraction operator
(includes ++, --, +=, =+, +, -) - Answers-False
This for loop will iterate 10 times: for(i=0; i!=0; i/=10) - Answers-True
This for loop will iterate 5 times: for(i=12345; i!=0; i/=10) - Answers-True
This for loop will iterate 6 times: for(i=1; i<=32; i*2) - Answers-False
This short-circuit method of evaluating logical expressions does not apply to loop control expressions -
Answers-False
Control-forcing statements such as break, continue, and the use of multiple return statements in a user-
defined function are prohibited by course standards as mechanisms to terminate repetitive processes -
Answers-True
The condition in a recursive function when which the recursive function calls stop is known as the best
case - Answers-True
Recursion should not be user with event-controlled processes as the result may be more function calls
than the memory of the computer can handle - Answers-True
A large number of recursive function calls may result in a crash due to running out of memory - Answers-
True
An iterative solution is one that is implemented using a looping construct - Answers-True