blogger Indonesia

Follow judhyns blog

THE break STATEMENT

Introduction

Just like the switch statement, break is used to break any type of loop. Breaking a loop means terminating it. A break terminates the loop in which the loop body is written.

Program/Example

For example,

i = 0; while (1) {     i = i + 1;     printf(" the value of i is %d\n");     if (i>5) break; } 

Explanation

  1. The while (1) here means the while condition is always true.

  2. When i reaches 6, the if condition becomes true and break is executed, which terminates the loop.

No comments:

feed

PR Check

activesearchresults

judhyn's blog

 

http://www.judhyn.blogspot.com | |