I don't understand why this program is making me input two more times (after the program is finished) before it terminates. All other programs that I do usually terminates while this code idles. For those who are confused, I have to enter extra characters and hit "enter," twice before the program terminates.
#include <iostream>
using namespace std;
int main()
{
//I'm declaring some variables.
int number1, number2, product, sum;
cout << "Please enter an integar (whole number): \n";
cin >> number1;
cout << "Please enter a another integar: \n";
cin >> number2;
//Computing the numbers.
product = number1 * number2;
sum = number1 + number2;
//This will reveal the final computations.
cout << "The sum of " << number1 << " and " << number2 << " equals: " << sum << "\n";
cout << "The product of " << number1 << " and " << number2 << " equals: " << product << "\n";
cin >> sum >> product;
return 0;
}
Also, I don't understand this program:
#include <iostream>
using namespace std;
int main()
{
char text[10];
cout << "Please enter a word: \n";
cin.getline(text, 10);
cout << text << endl;
return 0;
}
I can't seem to figure out what cin.getline() means. The book that I'm learning from explains it very vague. And it doesn't do anything special. Should it? When I run the program, it terminates after I input something.