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

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 
	
		
Why do you need to do this without returning or using exit()?
My professor doesn't want us to
This does not end the program immediately
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
Topic archived. No new replies allowed.