U3: Loops Flashcards
1
Q
Loops
A
- Allow programmer to see patterns in problems and write program accordingly
- Limited code repeats infinitely
2
Q
Infinite Loop
A
Loop that doesn’t stop (not good for program)
3
Q
For Loop [A]
A
- Exists in wide variety of languages; works similarly in all
- Has built-in variable keeping track of no. of loop executes
4
Q
For Loop [B]
A
- Starts at certain number; ends at certain number
- Can be incremented or decremented by given number
5
Q
Purpose of For Loop
A
- When times loop needed to execute already known
- When variable used to indicate no. of loop executes
6
Q
While Loops
A
- Used when programmer doesn’t know no. of times loop needs to repeat
- while; do while
7
Q
“While” Loop
A
Used for executing loop +0 times
8
Q
“Do While” Loop
A
Used for executing loop +1 times
9
Q
System.out.print vs. system.out.println
A
- System.out.print prints in single line repeatedly
- System.out.println prints in different lines repeatedly
10
Q
How User Input Influences Loops
A
Can change no. of times loop executes; exit program
11
Q
Data Structure
A
- Specific way to organize large amounts of same type of data
- Can store, process and output data
- Arrays, stacks, queues, linked lists
11
Q
Nested Loops
A
Loops inside of loops