Answer to Question #264880 in C++ for jev

Question #264880

unconditonally transfer program control within a function


1
Expert's answer
2021-11-12T00:55:17-0500
  • 1. goto
  • 2. break
  • 3. continue
  • 4. return

example:

#include <iostream>


using namespace std;


int sm = 0;


int main()
{
  while (true) {
    int n;
    cout << "Input a number: ";
    cin >> n;
    if (n < 0) {
      break;
    } else sm += n;
  }
  cout << "The sum is: " << sm << '\n';
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS