Hi am working on this program that will display the sum, difference, product and quotient of two numbers using the selection structures. This is what I did:
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
int num1 = 0;
int num2 = 0;
int answer = 0;
char operation;
int main()
{
cout << "Enter first number: ";
cin >> num1;
cout >> "Enter 1 (add) or 2 (subtract) or 3 (multiply) or 4 (divide): ";
cin >> operation;
cout << "Enter second number: ";
cin >> num2;
if (operation == 1)
{
answer = num1 + num2;
cout << "Sum: " << answer << endl;
}
else
if (operation == 2)
{
answer = num1 - num2;
cout << "Difference : " << answer << endl;
}
else
if (operation == 3)
{
answer = num1 * num2;
cout << "Product: " << answer << endl;
}
else
if (operation == 4)
{
answer = num1 / num2;
cout << "Quotient: " << answer << enl;
} //end if
system ("pause");
return 0;
} //end of main function
but am getting this errors:
error C2784: 'std::basic_ist ream<char,_Trai ts> &std::operat or >>(std::basic_i stream<char,_Tr aits> &,unsigned char &)' : could not deduce template argument for 'std::basic_ist ream<char,_Trai ts> &' from 'std::ostream'
Could someone be kind enough to let me know what's wrong with my code????
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
int num1 = 0;
int num2 = 0;
int answer = 0;
char operation;
int main()
{
cout << "Enter first number: ";
cin >> num1;
cout >> "Enter 1 (add) or 2 (subtract) or 3 (multiply) or 4 (divide): ";
cin >> operation;
cout << "Enter second number: ";
cin >> num2;
if (operation == 1)
{
answer = num1 + num2;
cout << "Sum: " << answer << endl;
}
else
if (operation == 2)
{
answer = num1 - num2;
cout << "Difference : " << answer << endl;
}
else
if (operation == 3)
{
answer = num1 * num2;
cout << "Product: " << answer << endl;
}
else
if (operation == 4)
{
answer = num1 / num2;
cout << "Quotient: " << answer << enl;
} //end if
system ("pause");
return 0;
} //end of main function
but am getting this errors:
error C2784: 'std::basic_ist ream<char,_Trai ts> &std::operat or >>(std::basic_i stream<char,_Tr aits> &,unsigned char &)' : could not deduce template argument for 'std::basic_ist ream<char,_Trai ts> &' from 'std::ostream'
Could someone be kind enough to let me know what's wrong with my code????
Comment