Explain the continue statement, C/C++ Programming

Assignment Help:

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;

 }

 


Related Discussions:- Explain the continue statement

Advantages of using pointers over arrays, Question : (a) Define a Poin...

Question : (a) Define a Pointer. Provide an example of an integer pointer variable. (b) Give advantages of using pointers over arrays. (c) Declare an integer pointer

Describe how can i allocate/unallocate an array of things?, A: Use p = new ...

A: Use p = new T[n] and delete[] p:   Fred* p = new Fred[100]; ... delete[] p; Any time you allocate an array of objects through new (generally with the [n] in the n

Described friend?, A: Something to let your class to grant access to anothe...

A: Something to let your class to grant access to another class or function. Friends may be either classes or functions. Class grants access privileges to its friends. In genera

Decode the code, Smugglers are becoming very smart day by day. Now they hav...

Smugglers are becoming very smart day by day. Now they have developed a new technique of sending their messages from one smuggler to another. In their new technology, they are send

I want a reverse engineer a .exe to obtain the code, I want a Reverse engin...

I want a Reverse engineer a .exe to obtain the code Project Description: I'd like to get the full C++ source code from a .exe please Skills required is C++ Programming

C program to add two polar coordinates, Aim: To implement a program to add...

Aim: To implement a program to add two polar coordinates using operator overloading. Code:                       #define PI 3.14 class polar {             double

Data Handling in computers, though the ascii is called 7-bit code. why do w...

though the ascii is called 7-bit code. why do we use 8-bits to represent a character?

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd