Question

Design a For loop that displays the following set of numbers: 0, 10, 20, 30, 40,...

Design a For loop that displays the following set of numbers:

0, 10, 20, 30, 40, 50,..., 1000

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

a For loop that displays the following set of numbers: 0, 10, 20, 30, 40, 50,..., 1000

Class Test

{

public static void main(String args[ ] )

{

int n;

for(n=0; n<=1000; n=n+10)

System.out.println("N:" +n);

}

  }

Explanation : initialization portion of the loop sets the value of the variable that act as a counterit executes first when the loop starts.And it is executed only once.when the control goes to condition,condition is evaluated.it condition is true ,the body of loop is executed.otherwise the loop terminates.Next iteration portion is executed which helps to increement or decreement the control variable.the loop then iterates the evaulating condition ,then executing the body and then executing the iteration portion eact time it iterates.

Add a comment
Know the answer?
Add Answer to:
Design a For loop that displays the following set of numbers: 0, 10, 20, 30, 40,...
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