cout <<"Enter the sign ( + , - , * , or /\n";
cin >> sign;
cout <<"Enter another number.\n";
cin >> b;
if(sign == "+")
{
sum = a + b;
cout <<"The answer of" << a << sign << b << "is:" << sum << endl;
}
else if(sign == "-")
{
sum = a - b;
cout <<"The answer of" << a << sign << b << "is:" << sum << endl;
}
else if(sign == "*")
{
sum = a * b;
cout <<"The answer of" << a << sign << b << "is:" << sum << endl;
}
else if(sign == "/")
{
sum = a / b;
cout <<"The answer of" << a << sign << b << "is:" << sum << endl;
}
else
{
cout<<"You entered an invalid sign."<<endl;
}
return 0;
}
One problem...
On lines 33, 38, 43, and 48 I get this error
Final\main.cpp|33|warning: comparison with string literal results in unspecified behaviour [-Waddress]|
C:\Users\Stoltz\Desktop\Codeblock Projects\Calculator Final\main.cpp|33|error: ISO C++ forbids comparison between pointer and integer [-fpermissive]|
Oops didn't see the answer after dput's first response...
I just started C++. I don't know what char is...
can you explain it to me please?
Thanks alot!
Character types: They can represent a single character, such as 'A' or '$'. The most basic type is char, which is a one-byte character. Other types are also provided for wider characters.