answersLogoWhite

0


Best Answer

There is insufficient information in the question to properly answer it. You did not provide the example "here". Please restate the question.

User Avatar

Wiki User

12y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Why a for loop is more appropriate here than a while loop?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

How many times is ado while loop guaranteed for a loop?

one or more


What are the components of loop?

a loop consist of data initialization;test condition;updation; example a for loop for(int a=1;a<5;a++) the loop will be executed 5 times four positives result and the last test condition will be failed and the loop will be exited there are many loops some of them are while loop,do...while loop,for loop,maybe more...... do while is an exit check loop and while and for are entry check loop.


Find factorial at given number using do while loop?

Actually, a for loop is more appropriate in this case. With while, it would be something like the following pseudocode - adapt to your favorite programming language:function factorial(n)result = 1factor = 1while factor


What are while loop in vb.net?

The while loop in vb.net uses the syntax form which provides a way to continue iterating while one or more conditions are true.


Examples of while loop?

// Infinite while loop while(true) { System.out.println("Still looping..."); } // More useful while loop to move through all elements in a Queue Object currentItem; while((currentItem = queue.poll()) != null) { System.out.println(currentItem); }


What are the differences between Do While and For loops in C?

In short, a for loop declares an variable and assigns it a value, has an argument, and has an update. A while loop only has an argument. More Detail... in C++, which is very close to C an example while loop is; while(i


Compare While with for Statements?

The while loop is the more general one because its loop condition is more flexible and can be more complicated than that of a for loop. The condition of a for loop is always the same and implicit in the construction. A for loop stops if there are no more elements in the collection to treat. For simple traversals or iterations over index ranges it is a good advice to use the for statement because it handles the iteration variable for you, so it is more secure than while where you have to handle the end of the iteration and the change of the iteration variable by yourself.


What is different between while and for loop in c plus plus?

Although both can achieve very similar loops, the one you use for a specific loop usually comes down to whichever seems more intuitive to you. In terms of performance, one method may be slightly more efficient than the other, however there are no general rules that can be applied; you must test each case by comparing the machine code or by physically timing the loops with a high performance event timer (HPET). In my experience, the performance difference is so negligible it is not worth the effort. Background activity has a far greater impact on performance.Describing the differences between every possible loop you might create would take me a lifetime, but there are a couple of subtle differences that are worth pointing out.Infinite Loopsfor(;;){} // infinite for loops do not require a condition.while( true ){} // infinite while loops MUST have a condition.To break out of an infinite loop you must test for one or more conditions within the loop itself, and call break to exit the loop when a condition is met. You can also call continue to start the next iteration before reaching the end of the current iteration.Stepping LoopsWhen stepping through a series of values, the for() loop is usually the better choice, especially if the step must occur AFTER each iteration. Consider the following similar loops:for( int x=0; x


What is the difference between while loop and for loop in c computer language?

For while loop you have to define conditions for the loop in loop's body. In, "for loop" case it's more natural and comportable. For loop is good for numeric simulations in other words when you are using only numbers. Loop while is very good for symbolic conditions, for instance, to check the condition that char1 == char2;


Is a DOWHILE loop more flexible than a dountil loop?

No, they are equivalient. DO something WHILE condition; does the same thing as DO something UNTIL NOT condition;


Which loop is most fastest in c plus plus?

In terms of performance there is no difference whatsoever. Which version you use is usually decided by which is more appropriate for the type of loop you want to execute. for() loops allow you to combine an initial condition, a conditional expression and a loop expression in a single statement. The initial condition can include a declaration which falls from scope when the loop ends, but all expressions are optional. If a conditional expression is not declared, a conditional expression must appear in the body of the loop. while() loops are similar to for() loops, but are generally used when an initial condition and loop expression are not required, but a condition is. The condition is non-optional. do..while() loops are used when a loop must execute at least once, and a condition is not optional.


What is the most basic loop in c?

Answerthe answer to this question would vary from programmer to programmer... Basically for the embedded system programmer the while loop is more important and would be considered as basic. However for the application programmer the for loop is always a better option.AnswerThese are: LABEL-goto, while, for, do-while, and recursion, of course.