the continue statementthe continue statement


The continue statement

The continue statement causes the next iteration of the enclosing loop to start. When this is encountered in the loop , the rest of the statements in the loop are leave out and control passes to the condition.

Let us see an example that accepts a variable amount of numbers from the keyboard and prints the sum of only positive numbers.

e.g.

void main()

 {

  int num, total = 0;

 

do

 {

cout << " enter 0 to quit ";

cin >> num;                        // equivalent to scanf()

if(num == 0)

break;

if(num < 0)

continue;

total+=num;

 }

while(1);

cout << total;

 }

 

Request for Solution File

Ask an Expert for Answer!!
C/C++ Programming: the continue statementthe continue statement
Reference No:- TGS0309279

Expected delivery within 24 Hours