   exe doesnt open
  Hello. I was playing around with variables a few days ago, here's the source#include <iostream>using namespace std;int main (){  int c=3;  int a=5;  int b(2); int result;    a = a + 3;  result = a - b;  cout << result + c;  return 0;  system("PAUSE");}When I built and ran the program it worked fine, but when I open up the saved exe it immediately closes. What am I doing wrong? Thanks.   
  Move the pause up to before you return 0 and exit the program?   ;  When your code reaches the return statement it returns whatever value you've used (in this case 0, to indicate success) to the calling code.  Any lines after the return will therefore not be executed.  In your code sample, you would want to move the system("PAUSE"); statement to the line above the return 0; like so:#include <iostream>using namespace std;int main (){int c=3;int a=5; int b(2); int result; a = a + 3;result = a - b;cout << result + c;system("PAUSE");return 0;}It would be better practice however to remove the system("PAUSE") call entirely and to either use the appropriate option in your IDE (in Visual Studio you would use "run without debugging") or actually run your program from the console.  The use of an artificial pause probably won't hurt you in small example programs, but just be aware that it isn't something that should be done in a proper program.   ;  I'd set a breakpoint on the return 0; statement for testing purposes. [smile]   ;  when im making dos programs i usualy just drag and drop the into the DOS/windows prompt thing.   ;  Thank you for replies, problem sorted   