   Ending a program
  Is there a C++ statemnet that will end a program during runtime?(for example: a switch case (Q}Quit from a menuthat will close the program completly)   
  Any "return" statement within the main function will close the program.Values other than 0 will tell the OS (Windows, Linux) that the program aborted because of some error.For example:#include <iostream>int main(){    int userNumber;   cin >> userNumber;    if (userNumber > 10) { return 1; }    return 0;}This program would execute correctly if the user number is less than 11, (return 0 means everything went ok).If the number is higher than 10 it will end and return error code 1 to the system.This kind of program abortion should only be used on critical situations, such that make it impossible for the program to continue.You should always have a real quit() function that e.g. takes care of freeing allocated heap space even if most OS would do it automatically.   ;exit(0); should do the trick.   ;  You *can* immediately terminate a program in a lot of ways. std::exit() (in C++) is probably the most common one.You *should*, except in extremely unusual circumstances, design things so that you *don't need to* do that. Instead, cause the program to reach the end. For example, if main() currently contains a while(true) loop that reads characters, and you want to stop the program when you see a certain character, then you can just break out of the loop when you see it; since there's nothing else in main(), the program reaches the end. Better yet, see if you can arrange for the while-condition to check for that character.   ;  Thanks everyone for the responses.My program branches to a Quitscreen() and then returns 0 fromthere. But it wants to sit at the _getch (screen pause) and not end the program.I think it's because it returns to a different function than the main()so, I might try doing a return 0 instead of Quitscreen() call and have the goodbye statement and _getch screen pause at the end of the main().If That doesn't clean it up, I might implement the exit().Tbank you very much for that very useful piece of information that,after reading several hundreds of pages of C++ books, fails to be in my toolbox for some odd reason.   ;  In the IDE when you run the program, when it ends it will wait till you press a key.  The IDE does this so you can analyze the data even if you did have it end too quickly.Run the .exe version in the debug folder and it will just close right away.   