I am teaching myself the basics of C++ with books and online tutorials. In C++ without fear, I am doing the small exercises about your first programs. I type them instead of copy and paste, can someone tell me what im doing wrong. I compile and run this program, after i input the number and press ENTER, it doesnt finish the program.
include <iostream>
using namespace std;
int main()
{
double n;
cout << "Input number and press ENTER: ";
cin >> n;
cout << "The square is: " << n*n;
return 0;
}
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
It runs to completion. When that happens the OS closes the program's window. This is perfectly normal behaviour you will have observed in other programs many times, but people are still often surprised when it occurs in their own code!
Note; we never tire of answering this question so perhaps the answer should be removed from the "PLEASE READ BEFORE POSTING A QUESTION" thread. (Note the sarcasm).
Clifford
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I am teaching myself the basics of C++ with books and online tutorials. In C++ without fear, I am doing the small exercises about your first programs. I type them instead of copy and paste, can someone tell me what im doing wrong. I compile and run this program, after i input the number and press ENTER, it doesnt finish the program.
include <iostream>
using namespace std;
int main()
{
double n;
cout << "Input number and press ENTER: ";
cin >> n;
cout << "The square is: " << n*n;
return 0;
}
It runs to completion. When that happens the OS closes the program's window. This is perfectly normal behaviour you will have observed in other programs many times, but people are still often surprised when it occurs in their own code!
Note; we never tire of answering this question so perhaps the answer should be removed from the "PLEASE READ BEFORE POSTING A QUESTION" thread. (Note the sarcasm).
Clifford
>it doesnt finish the program.
actually it does
run it from th command prompt and you'll see
and also read the "PLEASE READ BEFORE POSTING A QUESTION" thread