Test 5 Flashcards

1
Q

While loop benefits

A
  • Must REPEAT until certain condition met
  • Apply to numerous situations
  • If condition FALSE at the beginning, loop is NEVER EXECUTED
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

While loop format

A
int ctr=1;
while (ctr
{
System out print (ctr);
ctr++;
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Do-while benefits

A
  • ALWAYS EXECUTES body of loop at least once
  • Exit-condition
  • Good if ur asking a question who’s answer determines if the loop is repeated
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Do-while format

A
int ctr=1;
do
{
System.out.println(ctr);
ctr++;
}
while (ctr
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

For loop

A

Repeated a specific #of times

Allows u to input # of repetitions

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

For loop format

A

int ctr=1;

for(ctr=1; ctr

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

Each pass through a loop is called an

A

Iteration

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

In a group of nested loops, which loop is executed the least #of times?

A

Outer

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

Nested loops

A

Outer loop changes after inner loop is completely finished

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

for (rows=0;rows

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

Nested for loop with output:
N
NN

A

The inner would be

for (col=0; col

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

What’s wrong? int x=4; while(x>1) x++;

A

The loop is an infinite

Fix: int x=1; while(x

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