183k views
2 votes
Write a for loop that displays the following set of numbers: 0,10,20,30,40,50....1000

1 Answer

1 vote
C# program code:

int i = 0
while (i<=1000)
{
console.Writeline("{0}",i);
i = i + 10;
}

Step-by-step explanation:
First we set variable to initial value. In this example it is 0. Then we enter into while loop. This type of loop executes the code until the condition is fulfilled. In our case while loop checks if i <=1000. It is and then it writes it on the screen. Next step is to increase it by 10. Then it does the same code again.
Last number that will be printed is 1000. After that it will increase i to 1010 and it will exit the loop.
User VikramV
by
7.5k points