I just started to learn C ++, and I wrote this sample program from the text, and when I compile and run it, it just closes after the user enters any number and presses. I guess the answer to this is very obvious, so forgive me as a newbie here ... this is really my first C ++ program: P
#include <iostream>
using namespace std;
int main ()
{
int numberOfLanguages;
cout << "Hello Reader.\n"
<< "Welcome to C++.\n"
cout << "How many programming languages have you used? ";
cin >> numberOfLanguages;
if(numberOfLanguages < 1)
cout << "Read the preface. You may prefer.\n"
<< "a more elementary book by the same author.\n";
else
cout << "Enjoy the book.\n";
return 0;
}
user637965
source
share