Microsoft Windows
C Programming
C Sharp

What is a While Loop in C?

Top Answer
User Avatar
Wiki User
Answered 2010-06-12 14:10:50

"while" is an entry controlled loop statement i.e the condition is evaluated first and if it is true the body of the loop is evaluated.This process is repeated until the test condition is false;then the control is transfered out of the loop.

The general form of while is as following


while (<condition>)




User Avatar

Your Answer


Still have questions?

Related Questions

What kind of loops are used in C?

For loop, while loop, do while loop and goto loop.

Is do while loop in c is exit controoled loop?


Which loop is also called an exit-condition loop in C programming?

The do while loop is also called an exit condition loop in c, c++, and java.

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

Do-while loop in c?


What is the difference between a do while loop and a for loop in c?

the counter variable cannot be initialized in while loop before entering into the block.

What is the definition of 'nested' in C programming?

In C a structure within a structure is called nested. For example, you can embed a while loop in another while loop or for loop in a for loop or an if statement in another if statement.

Where do you get loop the loop straws?

C, for loops, while loops, and do while loops are control structures forFor example, the following programs are functionally identical: While loop

How do you write an infinite loop using the while loop?

while (1) puts ("press Ctrl+C");

How a C program to find LCM using while loop?

how to find the lcm using while loop

What is the difference between the while and the until loop?

There is no "until" loop in C, C++, or Java. Are you thinking do {} while ()?If so, the while loop tests the condition at the top...while (condition) statement;... while the do while loop tests the condition at the bottom statement; while (condition);... In the first example, if the condition if false to start with, the loop will never execute, but in the second example, the loop will always execute at least once.

Types of loops in C Program?

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 the limitations of do while loop in c?


C plus plus looping statements?

There are basically 3 looping statements : 1. for loop 2. while loop while loop

What is iteration in c programming?

In iteration is an instance of a loop (for, while or do-while).

Do while loop?

The DO WHILE loop is like the WHILE loop very much, except for one thing. The WHILE loop is like an IF loop but it keeps on going. The WHILE loop needs to start, so the beginning, when you are setting the conditions, is exactly the same. When the WHILE loop is done, it goes back to right before the conditions. The DO WHILE loop starts the WHILE loop so that you can have a WHILE loop that does not start with conditions, but instead, needs conditions to keep on going. This might not be the exact syntax, because if it doesn't work try it without the semicolon after the while. And anyways, if that doesn't work, I started with C++, not C.doCONTENTwhile(CONDITIONS);The WHILE loop goes back to the DO if the conditions are matched. The DO happens without any conditions.:) :) :)

Why there is need of do while loop in c?

Not all programmers will be comfortable with a "do-while" loop, just as not all programmers will be comfortable with the "for(;;)" loop.Both are provided for your individual preference.

How do you use switches in c?

do WHILE loop defination

What is a repeat until loop?

In C and C++, a repeat until loop is created using a do-while loop structure. A do-while loop executes at least once and terminates when the while condition evaluates false, re-iterating the loop if the evaluation is true. This is in contrast to for and while loops which evaluate the condition at the start of each iteration, and may not execute at all. Which loop structure you use is determined by the type of loop. If you need to count the iterations with a control variable and/or perform one or more actions at the end of each loop then a for loop is generally best. If the loop is simply conditional then a while loop is best. And if the loop must execute at least once, then a do-while loop is best.

What is a difference between while and do while loop in c programming?

The while loop evaluates the loop expression first. If it is true, the loop body executes, and then the loop iterates with the loop expression. If the expression is initially false, the loop body will never execute.The do while loop evaluates the loop body first, then it evaluates the loop expression. If it is true, the loop iterates with the loop body. The loop body will execute at least one time, no matter what the outcome of the loop expression.

What is the Difference between while loop and for loop in C programming?

when use for loop user can assign the value of the variable inside the loop, while checking the condition. but in while loop he has to assign it out side of the loop. like for loop: for(i=5, n=2; i&lt;=8; i++) { n=n+5; } while loop: int i=5, n=2; while(i&lt;=8) { n=n+5; i++; }

While loop in C language?

While loop is one of the type of loops that C language offers, they are usually used when you are not concerned about the number of iterations a loop will follow. For example: char choice='y'; while(choice=='y') { scanf("%c",&amp;chocie); } the above code will work while the user enters y

What are the various loop control statement in c plus plus?

for while do while

How do you make a c plus plus program loop?

There are four ways to make a loop in C or C++, three of which are standard, and one of which (the goto) is non structured, non preferred... for (init_expression; test_expression; loop_expression) statement; while (loop_expression) statement; do statement; while (loop_expression); loop: statement; if (loop_expression) goto loop;

Is for loop is faster than while loop in turbo c plus plus compiler?

No, why did you think so?