How to end a program without using an exit statement or a return statement

Sep 25, 2013 at 11:42pm
Hello! I need to write a program that will end at certain points when data entered is invalid. For instance, if someone enters a value less than zero, an error message will show and the entire program will terminate. I can't use return (0); till the end of the program or an exit statement. I would really appreciate the help!

1
2
3
4
5
6
7
//Student will enter number of points earned
	cout << "Enter the number of points you have earned: "; 
	cin >> points; 

	//Error message will show if number below 0 is entered 
	
		
Sep 25, 2013 at 11:47pm
Why do you need to do this without returning or using exit()?
Sep 25, 2013 at 11:52pm
My professor doesn't want us to
Sep 25, 2013 at 11:56pm
Sep 26, 2013 at 12:22am
This does not end the program immediately
Sep 26, 2013 at 12:28am
Depends what you mean by "immediately".

The original requirement said: "if someone enters a value less than zero, an error message will show and the entire program will terminate."

In that example, the error message is displayed first, so clearly it cannot end immediately, it has to continue processing in order to output the message.

In fact I don't see the word "immediate" or anything with that meaning in the OP. I suggest you are over-thinking this.
Last edited on Sep 26, 2013 at 12:30am
Topic archived. No new replies allowed.