Log in
Sign up for FREE
arrow_back
Library

4 - for & while loops

star
star
star
star
star
Last updated over 4 years ago
13 questions
1
1
1
1
1
1
1
1
1
1
1
1
1
Question 1
1.

Question 2
2.

Question 3
3.

Question 4
4.

Question 5
5.

Question 6
6.

Question 7
7.

Question 8
8.

Question 9
9.

Question 10
10.

Question 11
11.

Question 12
12.

Question 13
13.

for loops are best suited for which of the following purposes?
Performing the same action on an increasingly smaller subset
Infinitely repeating actions
Counting
Actions repeating until a certain event occurs
Each time through a loop is called a(n)
Repeat
Go
Iteration
Fabulation
Which of the following is the right order of the parts of a for loop?
for( stop ; start ; step )
for( step ; start ; stop )
for( step ; stop ; start )
for( start ; stop ; step )
Which of the following counts through the numbers 0 to 9 inclusive?
for( int i=1; i<=9; i++ )
for( int i=1; i<=10; i++ )
for( int i=0; i<9; i++ )
for( int i=0; i<10; i++ )
Given the line of code:

i=i+1;

What can be said?
There are two steps in this code, first adding 1 to i then assigning the result back to i
This code won’t run because that is mathematically impossible
This code won’t run because i+1 is out of range
This is a loop within a single line that happens one more time
Which of the following has the same effect as i++ ?
i+1
i
i=i+1
I--
Why is it acceptable to use i as a counter variable?
That is conventional and common, i is short for “index”
I represents you, the programmer
i is short for “intensity” as in current
It is NOT acceptable
while loops are best suited for which of the following purposes?
Actions repeating until a certain event occurs
Counting
Infinitely repeating actions
Performing the same action on an increasingly smaller subset
Each time through a while loop is called a(n)
Iteration
Go
Repeat
Fabulation
Which of the following is the right template for a header line in a while loop?
Repeat
Go
Iteration
Fabulation
Which of the following is the right template for a header line in a while loop?
while( control_expression_is_false )
while
while( start ; stop ; step )
while( control_expression_is_true )
Which of the following counts through the numbers 0 to 9 inclusive?
int i=0;
while( i<9 )
{ i++; }
int i=0;
while( i<10 )
{ i++; }
int i=1;
while( i<=10 )
{ i++; }
int i=1;
while( i<=9 )
{ i++ }
What is wrong with the following code?

int i=0; while( i<100 ) {
Serial.println(i);
i++;
}
Serial.print("After the loop, i’s valuse is:");
Serial.println(i);
The variable i is out of scope after the while loop
The for loop header line is not formatted correctly
The variable i cannot be printed to the serial monitor
There isn’t anything wrong with this loop