HPlogo HP C/HP-UX Reference Manual: Workstations and Servers > Chapter 6 Statements

The do Statement

» 

Technical documentation

Complete book in PDF

 » Table of Contents

 » Index

The do statement executes the loop body one or more times until the expression in the while clause evaluates to 0.

Syntax

do statement  while (expression)

Description

The loop body is executed. The controlling expression is evaluated. If the value of the expression is nonzero, control passes to the first statement of the loop body. Note that the test for a zero value is performed after execution of the loop body. The loop body executes one time regardless of the value of the controlling expression.

Example

For example:

     i = 0;
do {
func (i);
i++;
} while (i<3);

This example calls the function func three times with the argument values of 0, 1, and 2.