-
Super Quick Help
Code:
#include <iostream>using namespace std;
int main()
{
int a;
int b;
int c;
cout << "Enter a number:" << endl;
cin >> a;
cout << "Enter a number:" << endl;
cin >> b;
c = a + b;
cout << "The sum of those numbers is:" << endl;
cout << c;
cin.get();
}
I wrote this, tried to run it and it just closes the console as soon as the program is finished. What did I do wrong?
-
Run your program in a separate command prompt window.
If you really want to do it this way, then insert a cin.ignore() before the cin.get() to ignore the newline character left in the input buffer from cin >> b;
-
-
-
I was curious, your compiler does not complain that you omit in
-
No, it is not required by the standard.
If omitted, the compiler will add an implicit return 0.