SourcePoint Intel Help

Table of Contents

break

Exit from a control block.

Syntax

break

Discussion

Use the break command ย to cause termination of the nearest enclosing while, do while, for, or switch command.

Example

To use a break construct to terminate the while loop when the variable n equals 0:

Command input:

define int2 n = 3t ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย // define integer variable

while (1) ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย // begin infinite loop

{

ย ย ย n -= 1 ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย // decrement variable n

ย ย ย printf("n=%d\n", n) ย ย ย ย ย ย ย ย ย ย ย ย // display value of n

ย ย ย if (n == 0) ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย // break when n is zero

ย ย ย ย ย ย break

}

Result:

n=2
n=1
n=0

Related Topics: