Chapter 4 Looping Structures Flashcards

1
Q

What is iteration?

A

An execution of a section of program code. Iterating means repeating that code again and again until a specific condition is met.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is a loop?

A

A loop is the actual sequence of program instructions that is repeated.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

In regards to the order of operations, which takes precedence: assignment or normal (conditional) operations?

A

Normal (conditional) operations

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

When stuck in an infinite loop, what combination of characters will allow you to exit the loop?

A

Ctrl+C. If Ctrl+C doesn’t work, you may have to end the task via Task Manager.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the primary difference between the while loop and the do while loop?

A

Within the “while loop”, the condition is placed in the beginning of the loop, is evaluated, and has to be TRUE for the loop to continue.

For the “do while loop”, the condition is placed at the bottom of the loop after the loop’s closing brace with a semicolon at the end and does not have to evaluate to TRUE for the loop to begin. Although, will only run once if condition is FALSE.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the difference between a “for” loop and a “while” or “do while” loop?

A

A “for” loop is used when the number of iterations (loops) is already known (Ex. Repeat 5 times).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What are the 3 expressions found within a “for” loop?

A
  1. Variable initialization (x=0)
  2. Conditional expression (x<10)
  3. Increment/decrement (x++)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is the difference between “break” and “continue” statements within a loop?

A

A “break” statement following a condition will terminate the loop when the condition is met.

A “continue” statement following a condition will pass over any remaining statements in the loop and continue the next iteration in the loop.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What function can be used to call Operating System commands such as the UNIX “clear” command?

A

The “system” function.

Ex: system (“clear”);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly