Return 0; Is not Working

Jan 28, 2012 at 6:18am
1
2
3
4
5
6
7
8
9
10
11
12
// conditional operator
#include <iostream>
using namespace std; 
int main () 
{ 
  int a,b,c; 
  a=2; 
  b=7; 
  c = (a>b) ? a : b; 
  cout << c; 
  return 0; 
}

As you see here I have no errors at all and it keeps on skipping the cmd instead of showing it for more than 1 second. Whats the problem, am I missing something?
Jan 28, 2012 at 6:32am
On windows the console window automatically shut down when the program ends. I think you can change some settings to make it stay open. If you run it from an IDE there is probably some IDE settings you change. If you first open the command prompt and start the program from there you will also be able to see the output.
Last edited on Jan 28, 2012 at 6:32am
Jan 28, 2012 at 6:47am
My IDE is Dev-C++.
Jan 28, 2012 at 7:08am
try ctrl F5
Jan 28, 2012 at 7:47am
There's a big sticky about this:

http://cplusplus.com/forum/beginner/1988/
Jan 29, 2012 at 7:35am
^ Did Not Work :( ^
Jan 29, 2012 at 7:40am
1
2
3
cout << c;
cin.get(); // <-
return 0;
Topic archived. No new replies allowed.