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

Padovan string, #questio#A Padovan string P(n) for a natural number n is de...

#questio#A Padovan string P(n) for a natural number n is defined as: P(0) = ‘X’ P(1) = ‘Y’ P(2) = ‘Z’ P(n) = P(n-2) + P(n-3), n>2 where + denotes string concatenation. For a string

When should you use multiple inheritance, There are 3 acceptable answers: "...

There are 3 acceptable answers: "Never," "Rarely "and" When the problem domain cannot be accurately modelled any other way."

Pseudo code, determining whether an integer is prime number or not

determining whether an integer is prime number or not

Substr and random pick file from directory, Hello I''m new to programming, ...

Hello I''m new to programming, and I''m making now my 1st program. My question is how to put substr in textbox that question mark should be at the end of sentence? And 2nd question

Explain about the expressions in c language, Explain about the Expressions ...

Explain about the Expressions in c Language? An expression is the combination of constants, variables and operators arranged as per the syntax of the language. Some of the illu

The use of the break and continue statements in a loop, Question: (a) ...

Question: (a) A bank has four types of accounts with annual interest rates as follows: Savings 8% Savings with Cheque Book 5% Current 4% Fixed deposits 10% Using

Psudo code for interrupt handler , The rPeANUt simulator provides buffering...

The rPeANUt simulator provides buffering of the characters that are typed into the terminal. However, this would generally not be the case so if the program did not consume a chara

Calculate the discharge by c program, #include stdio.h #include math.h ...

#include stdio.h #include math.h float discharge(float,float); void main()   {   char prompt;      float time,out,cr;   cr = 100e-6;   for (time = 0;time   {   /* call th

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