NEW
Font size
WorksheetsArduino Loop
Total questions: 20
Worksheet time: 11mins
In programming, what is iteration?
The repetition of steps within a program
The order in which instructions are carried out
A decision point in a program
Testing a program to make sure it works
FOR loops are
loops which run an unknown number of times
loops which run for a specific number of times
the same as if statements
not part of programming
Which of the following is the correct format of a "for" loop?
for(int i = 0; i < 10; i++);
for[int i = 0; i < 10; i++];
for(int i = 0; i < 10; i++)
for[int i = 0; i < 10; i++]
What type of a loop is a for loop?
Fixed Length
Variable Length
Infinite Length
Imaginary Length
How many times will the shown for loop execute?
0
9
10
11
How many times will the shown for loop execute>
0
100
20
50
What are the three parts of a for loop?
initialize; test; increment
test; initialize; increment
increment; test; initialize
Larry; Mo; Curly
What output is produced by the following segment of code:
for(int i = 0; i < 10; i++)
cout << i << " ";
0 1 2 3 4 5 6 7 8 9 10
0 1 2 3 4 5 6 7 8 9
1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9
Infinite Loop
What output is produced by the following segment of code:
for(int i = 0; i <= 10; i++)
cout << i << " ";
0 1 2 3 4 5 6 7 8 9 10
0 1 2 3 4 5 6 7 8 9
1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9
Infinite Loop
What output is produced by the following segment of code:
for(int i = 1; i <= 10; i++)
cout << i << " ";
0 1 2 3 4 5 6 7 8 9 10
0 1 2 3 4 5 6 7 8 9
1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9
Infinite Loop
What output is produced by the following segment of code:
for(int fun = 20; fun > 1; fun -=3)
cout << fun << " ";
20 17 14 11 8 5 2 -1
20 17 14 11 8 5 2
17 14 11 8 5 2 -1
20 17 14 11 8 5
Infinite Loop
What output is produced by the following segment of code:
int start = 5;
int end = 20;
for(; start <= end; start +=2)
cout << start << " ";
5 7 9 11 13 15 17 19 21
7 9 11 13 15 17 19 20
7 9 11 13 15 17 19 21
5 7 9 11 13 15 17 19
Infinite Loop
What output is produced by the following segment of code:
for (int dmc = 8; dmc >= 0; dmc-=4)
cout << dmc << " ";
8 4 0
8 4
8
No Output
Infinite Loop
What output is produced by the following segment of code:
for (int dmc = 8; dmc >= 8; dmc-=4)
cout << dmc << " ";
8 4 0
8 4
8
No Output
Infinite Loop
What output is produced by the following segment of code:
for (int dmc = 8; dmc >= 10; dmc-=4)
cout << * << " ";
* * *
* *
*
No Output
Infinite Loop
What output is produced by the following segment of code:
for (int x = 5; x > 0; x--);
cout << * << " ";
* * * * *
* * * * * *
*
No Output
Infinite Loop
What does the following code print?
for( int w=3; w<=12; w++ )
cout << w << " ";
5 6 7 8 9
4 5 6 7 8 9 10 11 12
3 5 7 9 11
3 4 5 6 7 8 9 10 11 12
Make this code loop three times:
int tries= 0;
while(_________ ) {
cin>> “Looping!”;
tries++;
}
tries < 3
answer == 3
tries > 0
tries < 0
This code prints all tenths from 0 to 100.
int numbers = 0;
while( numbers <= 100 ){
cout << numbers << " ";
numbers+=10;
}
True
False
Which of the following 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 )
