WorksheetsCSNP-04103 Chapter 5 - Loops
Total questions: 10
Worksheet time: 5mins
Select all C++ repetition flow control structures.
Sequential
While Loop
If else
For Loop
Do - While
In c++ the statement x++; is equivalent to:
y = y + 1
x = x * 1
-x
x = x + 1
In C++ the statement countEmp +=1; is equal to:
countEmp = 1;
countEmp ==1;
countEmp = countEmp + 1;
None of the above.
Counter controlled loops are useful when:
You don't know the number of interactions in the loop in advance
You know the number of interactions needed in the loop in advance
You need to repeat something
You need to make a selection
In a loop what happens when the control variable is not properly updated?.
You won't get the proper answer.
Your program will not run.
You may get an infinite loop.
The parser will tell you.
Which C++ flow control repetition structure has on its header the initialization, condition and increment?.
Do While
While Loop
If Else
For Loop
The instruction setw(<number>) belongs to the library:
<iosteam>
<cmath>
<string>
<iomanip>
Conditional (while - Do while) loops are mostly used when:
You know in advance the number of interactions in the loop.
You can't determine before the loop execution the number of interactions.
When you need to increase a value.
When you need to count values.
What are the part of a conditional while loop:
initialization, condition, increment
initialization, selection , execute
initialization, test condition, execution, update condition
None of the above.
The difference between a while and a do while is:
Only the Do word.
The Do while will execute at least once.
The Do while will evaluate the condition first
The Do While increment happens after the condition is tested.
