Java While Loops

Ace your homework & exams now with Quizwiz!

0

This loop prints _____________ int pqr = 0; while( pqr < 3 ) { ....System.out.print( pqr + " "); ....if(pqr > 10) ....{ ........break; ....} ....pqr += 3; }

0 3 6

This loop prints _____________ int pqr = 0; while( pqr < 9 ) { ....System.out.print( pqr + " "); ....if(pqr > 10) ....{ ........break; ....} ....pqr += 3; }

0 3 6 9 12

This loop prints _____________ int pqr =0; while( pqr < 100 ) { ....System.out.print( pqr + " "); ....if(pqr > 10) ....{ ........break; ....} ....pqr += 3; }

0 3 6 9

This loop prints _____________ int pqr =0; while( pqr < 100 ) { ....if(pqr > 10) ....{ ........break; ....} ....System.out.print( pqr + " "); ....pqr += 3; }

0 3

This loop prints _____________ int pqr =0; while( pqr < 5 ) { ....System.out.print( pqr + " "); ....if(pqr > 10) ....{ ........break; ....} ....pqr += 3; }

7 6 5 4 3 2 1 0

This prints ________ int m = 7; while( m >= 0 ) { ....print(m + " "); ....m--; }

A AA AAA

What does this print? String letter = "A"; int m=1; while( m<=3 ) { ....println(letter); ....letter = letter + "A"; ....m++; }

1 5 9 13 17

What does this print? int max = 20; int num = 1; while( num < max ) { .... println(num); .... num+=4; }

5 9 13 17 21

What does this print? int num = 1, max = 20; while (num < max) { ...num += 4; ...println(num); }

exit a loop quickly

What is the break keyword used for? You should try it in a loop to see how it works.

This is an infinite loop.

What is wrong with this code? double number = 2.0; while (number <= 20) { ....println(number); ....number -= 2.0; }

i=5 i<=25 i=i+5 "i="+i

Write a loop that prints i=5 i=10 i=15 i=20 i=25 int ________; while ( ___________ ) { .... System.out.print( _________ ); .... _________ }

-4 1

Write a loop that prints: -4 -3 -2 -1 0 1 2 3 int cnt = ______; while ( cnt <= 3 ) { ....print(cnt + " "); ....cnt += ______; }

3 i++

Write a loop that prints: 3 4 5 6 7 8 9 int i = _______; while( i <= 9 ) { ....print(i + " "); ...._______________; }

14 2

Write a loop that prints: 6 8 10 12 14 int ii = 6; while( ii <= ________ ) { ....print(ii + " "); ....ii += ______); }

6 2

Write a loop that prints: 6 8 10 12 14 16 int ii = _______; while( ii <= 16 ) { ....print( ii + " " ); ....ii += ______ }

count-5

count-=5 is the same as count = ______

idx+1

idx++ is the same as idx = _______

k-1

k-- is the same as k = _______

mm+5

mm+=5 is the same as mm = _______


Related study sets

Baking Tools and Equipment (definition)

View Set

CH. 8: The Chemical Senses Taste & Smell

View Set

Principles of Macroeconomics Chapter 6

View Set

Functions of the Skeletal System

View Set

Primerica Chapter 3: Life insurance policies

View Set

I. ABDOMINAL REVIEW - 12. The Face & Neck

View Set

Med Surg Acid Base, Fluid, Electrolyte

View Set