Font size
WorksheetsLoops
Total questions: 19
Worksheet time: 11mins
Make this code loop three times:
int tries= 0;
while(_________ ) {
cin>> “Looping!”;
tries++;
}
tries < 3
answer == 3
tries > 0
tries < 0
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 - - ;
}
Fill in the blank to make this code print Go Heat!
3 times
int loop = 0;
while(__________) {
cout<<“Go Heat”<<endl;
loop++;
}
loop < 3
answer == 3
loop = 0
loop == 3
Fill in the blank with the right symbol to make this code print I'm a coder 3 times
int loop = 0;
while(loop (a) 3) {
cout<<“I'm a coder”<<endl;
loop++ ;
}
Select all of the statements properly increments an int variable by one?
variable++;
variable += 1;
variable + 1;
variable = variable * variable;
Select all of the statements properly decrements an int variable by one?
variable = variable - 1;
variable -= 1;
variable - -;
variable - variable;
variable - 1;
True or False. This code prints all tenths from 0 to 100
int numbers = 0;
while(numbers <=100) {
cout<<numbers<<" ";
numbers+=10;
}
True
False
What does <= mean?
less than
greater than
less than or equal to
greater than or equal to
Which of the following is NOT a logical operator in C++ language?
&
&&
||
!
Which of the following is NOT a comparison operator in C++ language?
>
<=
=
==
The cout statement in the following program segment will display 5:
int x = 5;
cout << x++;
True
False
Which of the following while-clauses tells the computer to exit the loop when the value in the age variable is less than the number 0?
while (age < 0)
while age >= 0;
while (age !> 0)
while (age >= 0)
Values that are used to end loops are referred to ______
values.
closing
ending
sentinel
stop
What's wrong?
while( (i < 10) && (i > 24))
the logical operator && cannot be used in a test condition
the while loop is an exit-condition loop
the test condition is always false
the test condition is always true
The statement i*=3 is equivalent to ____.
i = 3*
i = 3
*i = 3
i = i * 3
The expression c = i++ causes ______.
the value of i assigned to c and then i incremented by 1
i to be incremented by 1 and then the value of i assigned to c
value of i assigned to c
i to be incremented by 1
How many times will the computer process the statement in the following code?
int x = 0;
while (x > 3)
{
cout << x << endl;
x = x + 1;
}
0
2
3
4
What will be displayed when the following code is executed?
int number = 6;
while (number > 0)
{ number -= 3;
cout << number << " "; }
6 3 0
6 3
3 0
0 -3
