hi,
i am basically a newbie to C++ and tried to make this simple math program but came acroos this error and don't know how to resolve it:
#include <iostream>
#include <cmath>
#include <string>
using namespace std;
int main(void)
{
string input = Add;
int a, b;
cout << "What would you like to do? (Add, Subtract, Multiply, Divide) ";
cin >> input;
if (Add)
{
cout << "Enter a value: ";
cin >> a;
cout << "Enter another value: ";
cin >> b;
cout << "The sum of the numbers is " << a + b << endl;
}
else if (input = 'Subtract')
{
cout << "Enter a value: ";
cin >> a;
cout << "Enter another value: ";
cin >> b;
cout << "The difference of the two numbers is " << a - b << endl;
}
else if (input = 'Multiply')
{
cout << "Enter a value: ";
cin >> a;
cout << "Enter another value: ";
cin >> b;
cout << "The product of the two numbers is " << a * b << endl;
}
else if (input = 'Divide')
{
cout << "Enter a value: ";
cin >> a;
cout << "Enter another value: ";
cin >> b;
cout << "The quotient of the two numbers is " << a / b << endl;
cout << "And the remainder is " << a % b << endl;
}
return 0;
}
the error is saying:
limac@limac-kubuntu:~/Desktop$ g++ -o math math.cpp
math.cpp:15:14: warning: multi-character character constant
math.cpp:23:20: warning: character constant too long for its type
math.cpp:31:20: warning: character constant too long for its type
math.cpp:39:20: warning: character constant too long for its type
math.cpp: In function ‘int main()’:
math.cpp:10: error: ‘Add’ was not declared in this scope
math.cpp:15: warning: overflow in implicit constant conversion
math.cpp:15: error: could not convert ‘input.std::basic_string<_CharT, _Traits, _Alloc>::operator= [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>](100)’ to ‘bool’
math.cpp:23: warning: overflow in implicit constant conversion
math.cpp:23: error: could not convert ‘input.std::basic_string<_CharT, _Traits, _Alloc>::operator= [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>](116)’ to ‘bool’
math.cpp:31: warning: overflow in implicit constant conversion
math.cpp:31: error: could not convert ‘input.std::basic_string<_CharT, _Traits, _Alloc>::operator= [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>](121)’ to ‘bool’
math.cpp:39: warning: overflow in implicit constant conversion
math.cpp:39: error: could not convert ‘input.std::basic_string<_CharT, _Traits, _Alloc>::operator= [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>](101)’ to ‘bool’
limac@limac-kubuntu:~/Desktop$
if anyone can identify the error and inform me, I'd really appreciate that!
Thx