QUESTION 9 You must tell the user what value to type to end the loop for ____. c
ID: 3708451 • Letter: Q
Question
QUESTION 9
You must tell the user what value to type to end the loop for ____.
counter-controlled loops
state-controlled loops
sentinel-controlled loops
any type of loop
for loops
QUESTION 10
The while statement is the only type of loop construct that can be used to develop a sentinel-controlled loop.
True
False
QUESTION 11
What would be the result of the following conditional expression?
int i = 0;
while (i < 10) ;
i++;
Write(i);
123456789
012345678910
0123456789
an infinite loop
QUESTION 12
Unlike the sentinel-controlled loop, the variable used with a state-controlled loop differs from the variable used to store the data that is being processed.
True
False
counter-controlled loops
state-controlled loops
sentinel-controlled loops
any type of loop
for loops
QUESTION 10
The while statement is the only type of loop construct that can be used to develop a sentinel-controlled loop.
True
False
QUESTION 11
What would be the result of the following conditional expression?
int i = 0;
while (i < 10) ;
i++;
Write(i);
123456789
012345678910
0123456789
an infinite loop
QUESTION 12
Unlike the sentinel-controlled loop, the variable used with a state-controlled loop differs from the variable used to store the data that is being processed.
True
False
Explanation / Answer
any type of loop
for any loop, if the end condition (terminating condition) is not defined, the looping will go on infinite.
-------------------------------------------------
False,
even the for loop can also be used for senital controlled loops, just that we actually do not have the initialization part and the increment part so it makes no sense to use for loop like - for( ;user-input condition to continue loop ; )
hence, while loop is more preferred.
--------------------------------------
an infinite loop
int i = 0;
while (i < 10) ;
i++;
Write(i);
the snippet can be re-written as :
int i = 0;
while (i < 10)
{
// here no logic or increment in value of i is happening, therefore this loop termination condition will never meet.
};
i++;
Write(i);
------------------------------------------------------
True
for a state-controlled loop, it is not the same variable that is processing data and being checked for loop condition as well because the loop condition can be pre-defined.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.