Examples of continue statement in c++ programing
All Contributions
Example of write a program with continue statement and while loop :
#include <iostream>
using namespace std;
int main()
{
int sum = 0;
int number = 0;
while (number >= 0) {
sum += number :
cout << "Enter a number: ";
cin >> number;
if (number > 50) {
cout << "The number is greater than 50 and won't be calculated." << endl;
number = 0; // the value of number is made 0 again
continue;
}
}
cout << "The sum is " << sum << endl;
return 0;
}
total contributions (3)
Write a program with continue statement and nested loop :