Guess you are using one of the IDE's which closes the output window as soon as the program finishes executing.
use getch(); so that the program waits for a user input. that does the trick
While this is the right idea, it's not the right implementation. Getch() is from the non-standard library conio.h, which is different from system to system, and version to version, meaning it can mess things up if you don't have the exact same version across all systems.
A better way would be to, at the end of your program, prompt the user, "Press enter to end program" and then just have any sort of cin or scan() (as you don't mention if you are using C or C++), and just ignore the input values.