Question

What does the following nested loop print out? for (int r=1; r <=5; ++r) { double...

What does the following nested loop print out?

for (int r=1; r <=5; ++r) {

double x =10.0*r;

for (int c=1; c<=5; ++c) {

System.out.printf("%5.2f",c/x);

}

System.out.println();

}

0 0
Add a comment Improve this question Transcribed image text
Answer #1

5.2 is used to control the decimal places(2 decimal places).

Above program prints the pattern as follows:

1/10 2/10 3/10 4/10 5/10

1/20 2/20 3/20 4/20 5/20

1/30 2/30 3/30 4/30 4/30

1/40 2/40 3/40 4/40 5/40

1/50 2/50 3/50 4/50 5/50

(upto 2 decimal places)

Add a comment
Know the answer?
Add Answer to:
What does the following nested loop print out? for (int r=1; r <=5; ++r) { double...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT