WorksheetsFlow of Control in C++ ( Conditional statements)
Total questions: 17
Worksheet time: 9mins
Choose the multiway branch statement from the following.
if
for
if ... else
switch
Identify the exit control loop from the following.
for
while
do..while
if..else
This statement is used to terminate the execution of the loop
break
jump
goto
continue
Predict the output.
320 11 330
320 10 330
330 11 320
Predict the output
5
Empty Loop
No Answer
1234
Read the program carefully and give your output
Welcome Child!!!
Error
Welcome Child!!! Welcome Child!!!Welcome Child!!!
Identify the iteration statments from the following:
for
switch
if
while
do while
int i=1;
while(i<5)
{ cout<<i;i++; }
How many times the above loop will be executed?
5
1
Will not be executed at all
4
int i=1;
while(i<5)
{
i=1;
cout<<i;
i++;
}
Predict the output.
Infinite loop
1 2 1 2 1 2
5 times
Run time Error
Nesting of switch statment is allowed.
True
False
What is currect syntax of for loop?
for(initialization;condition; increment/decrement)
for(increment/decrement; initialization; condition)
for(initialization, condition, increment/decrement
None of These
The statement i++; is equivalent to
i = i + i;
i = i + 1;
i = i - 1;
i --;
Which looping process is best used when the number of iterations is known?
for
while
do-while
all looping processes require that the iterations be known
Make this code stop looping once you get the right answer:
string answer;
bool hasGuessed = false;
while(true) {
cin>> answer;
if (answer == “the right answer”){
__________
}
}
hasGuessed == false
hasGussed == true
hasGuessed = true;
hasGuessed = false;
Make this code loop three times:
in tries= 0;
while(_________ ) {
cin>> “Looping!”;
tries++;
}
tries < 3
answer == 3
tries > 0
tries < 0
Which of these statements stops a while loop?
stop;
break;
loop pause;
do { }
Fill in the blank with the right symbol to make this code print Tacos 4 times
int tacos = 4;
while(tacos (a) 0){
cout<<“Tacos”<<endl;
tacos - - ;
}
