What Is Looping Statement In C++
For the loop to work correctly add i;, just after the printf statement. Always remember, it is easy to forget update expression in while and do while loop, than in the for loop. The following is a C-style While loop.It continues looping while x does not equal 3, or in other words it only stops looping when x equals 3.However, since x is initialized to 0 and the value of x is never changed in the loop, the loop will never end (infinite loop). A conditional statement is widely used in any programming language to various logical programming expressions. Recommended Articles. This is a guide to While Loop in C. Here we discuss what is While Loop in C, Flow Diagram, How While Loop works in C and examples of While Loop in C. You can also go through our other suggested articles–. Create a function to perform the loop, give it a meaningful name, then just call it as the predicate of the if. – Nemo Jun 21 '11 at 1:19 Throwing in a space every once in a while would make it easier to read too – Brad Mace Jun 21 '11 at 1:21.
Looping Statement In C
- C++ Basics
- C++ Object Oriented
- C++ Advanced
- C++ Useful Resources
- Selected Reading
Unlike for and while loops, which test the loop condition at the top of the loop, the do...while loop checks its condition at the bottom of the loop.
A do...while loop is similar to a while loop, except that a do...while loop is guaranteed to execute at least one time.
Syntax

The syntax of a do...while loop in C++ is −
Notice that the conditional expression appears at the end of the loop, so the statement(s) in the loop execute once before the condition is tested.
If the condition is true, the flow of control jumps back up to do, and the statement(s) in the loop execute again. This process repeats until the given condition becomes false.
Flow Diagram
Example
Looping Statements In C#
When the above code is compiled and executed, it produces the following result −
