When you run a code, the console window appears and immediately disappears. So you don't get a chance to see the result or enter and user inputs. This happens with some Windows based compilers.
The solution to this problem is to include either of the following statements at the
end of your C/C++ code.
getch(); (Press any key to exit)
getchar(); (Press Enter to exit)
getc(stdin); (Press Enter to exit)
fgetc(stdin); (Press Enter to exit)
system("pause"); (Not recommended)
Online C/C++ compiler: http://www.techbugs.org/wiki/OnlineCompiler