Ciclo Do While En Dev C++

-->

Dec 19, 2014 Java Project Tutorial - Make Login and Register Form Step by Step Using NetBeans And MySQL Database - Duration: 3:43:32. 1BestCsharp blog Recommended for you. C while and do.while Loop Loops are used in programming to repeat a specific block of code. In this article, you will learn to create while and do.while loops in C programming.

Dev

Executes a statement repeatedly until the specified termination condition (the expression) evaluates to zero.

Syntax

Remarks

The test of the termination condition is made after each execution of the loop; therefore, a do-while loop executes one or more times, depending on the value of the termination expression. The do-while statement can also terminate when a break, goto, or return statement is executed within the statement body.

The expression must have arithmetic or pointer type. Execution proceeds as follows:

  1. The statement body is executed.

  2. Next, expression is evaluated. If expression is false, the do-while statement terminates and control passes to the next statement in the program. If expression is true (nonzero), the process is repeated, beginning with step 1.

Example

The following sample demonstrates the do-while statement:

See also

Iteration Statements
Keywords
while Statement (C++)
for Statement (C++)
Range-based for Statement (C++)

  • C++ Basics
  • C++ Object Oriented
  • C++ Advanced

Ciclo Do While En Dev C S En Dev C++ Ejemplos

  • 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

When the above code is compiled and executed, it produces the following result −

Ciclo Do While En Dev C++ Ejemplos

cpp_loop_types.htm