I just started learning C++ and I wrote this sample program from the text and when I compile and run it, it just closes after the user inputs any number and presses enter.
Either put another read from cin to wait for the user, or open the Command Prompt yourself and run it there.
cin