cin.get() Problems

Posts 1–4 of 4 · Page 1 of 1
cin.get() Problems
I got a problem with my program.

When i added "cin.get();" to the last statement, it always add a "10" at the end of my program when i use it.

Code:
#include <iostream>
using namespace std;

int main()
{
	double result, n, d;

	cout << "Enter value: ";
	cin >> n;

	cout << "Enter divisor: ";
	cin >> d;


	if(d != 0)
	{
		cout << "d does not equal zero so division is OK" << "\n";
		result = n/d;
		cout << n << " / " << d << " is " << result << cin.get();
	}
		cin.get();
		return 0;
	
}
Thank you in advance.
[php]
#include <iostream>
using namespace std;

int main()
{
double result, n, d;

cout << "Enter value: ";
cin >> n;

cout << "Enter divisor: ";
cin >> d;


if(d != 0)
{
cout << "d does not equal zero so division is OK" << "\n";
result = n/d;
cout << n << " / " << d << " is " << result; cin.get();
}
cin.get();
return 0;

}

[/php]

Fixed.
You need a ; after result to end the statement...

Code:
result = n/d; 
        cout << n << " / " << d << " is " << result; cin.get();
Ok, thank you so much Void and Vital!
Posts 1–4 of 4 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Talk with us