answersLogoWhite

0

Perhaps you meant something like this:

i=1-1; while (++i<=10) { printf ("%d\n"); } /* 1..10 */
i=10+1; while (--i>=1) { printf ("%d\n"); } /* 10..1 */

User Avatar

Wiki User

12y ago

Still curious? Ask our experts.

Chat with our AI personalities

MaxineMaxine
I respect you enough to keep it real.
Chat with Maxine
ProfessorProfessor
I will give you the most educated answer.
Chat with Professor
FranFran
I've made my fair share of mistakes, and if I can help you avoid a few, I'd sure like to try.
Chat with Fran

Add your answer:

Earn +20 pts
Q: How do you make a while loop go backwards?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

When should use a while loop over a do loop?

Generally speaking a for loop looks like this:for(Initialization;condition;increment){Do Stuff}whereas a while loop looks like this:while(condition){Do Stuff}Before the while loop there should be some initialization and somewhere in the Do Stuff section there should be statements that change the condition. Those statements are analogous to the increment section of the for loop.


What are the types of loops?

There are three forms of loop commonly used in C/C++, the for loop, the while loop and the do-while loop. The for loop is most commonly used whenever an action is going to be performed a set amount of times. For example, to sum every element in an array: for(i = 0; i &lt; arraySize; i++) { sum = sum + array[i]; } The while loop and do-while loop are commonly used to loop until a condition is met. The difference between the two is that the do-while loop goes through one iteration before checking its condition, while the while loop checks its condition before any execution of the loop. Example do-while loop: do { randomNumber = rand() % 10; }while(randomNumber != 6); Example while loop: cout &gt; number; while(number &lt; 0) { cout &gt; number; }


What is a while statement in turbo c plus plus?

A while statement is one type of looping statement. by which we can start a loop in our programs. while loop is precondition checking statement, because it first check its condition then loop will go to its body part. EX. while(i&gt;0) { //body part } here when i will &gt;0 then it will check it body part and execute it and display result.


What is the difference between a repeat until and a while do loop?

Repeat until loops run until a condition is true. They repeat at the end of the loop and they will always run at least once. While do loops will only run while a condition is true. They may not run at all.


Why does java script support more than one type of loop?

Think of a Javascript loop as a loop in a rollercoaster, which, as you know, makes you go back to the place you started the loop, and then continue. Javascript allows you to create sections of code that make the program handler to go back to the point specified, so instead of copying out a functions directions twice, you can tell the program to reference that section of code for the instructions, and then jump back to where it was.