Rewrite the programs TestBreak and TestContinue in Listings and without using break and continue.
Listing
1 #include
2 using namespace std;34 int main()5 {6 int sum = 0 ;7 int number = 0 ;89 while (number < 20)10 {11 number++;12 sum += number;13 if (sum >= 100)14 break;15 }1617 cout << "The number is " << number << end⌉;18 cout << "The sum is " << sum << end⌉;1920 return 0 ;21 }
Listing
1
2 using namespace std;34 int main()5 {6 int sum = 0;7 int number = 0;89 while (number < 20)10 {11 number++;12 if (number == 10 || number == 11)13 continue ;14 sum += number;15 }1617 cout << "The sum is " << sum << end⌉;1819 return 0 ;20 }
We need at least 10 more requests to produce the solution.
0 / 10 have requested this problem solution
The more requests, the faster the answer.