#include <iostream>
#include <math.h>
usingnamespace std;
int main()
{
char a, s, m, d; //variables for add, subtract, multiply, and divide;
int first;
int second;
char c;
int answer = 0;
cout << "SIMPLE CALCULATOR" << endl; //Title "**SIMPLE CALCULATOR**"
cout << "Enter first number: "; //Ask user for first number input
cin >> first >> endl; //Allow user input for first number
cout << "Enter second number: "; //Ask user for second number
cin >> second >> endl; //Allow user input for second number
cout << "Add [1], subtract [2], multiply [3], or divide [4]?: "; //Ask user for operator to be used
cin >> c >> endl;
if( c == 'a' )
{
answer = first+second;
}
if( c == 's' )
{
answer = first-second;
}
if( c == 'm' )
{
answer = first*second;
}
if( c == 'd' )
{
answer = first/second;
}
cout << "Your answer is: " << answer << endl;
return 0;
}
Trying to make a simple calculator but my code won't compile. Get this error message followed by a long string of text:
SimpleCalculator.cpp: In function ‘int main()’:
SimpleCalculator.cpp:16: error: no match for ‘operator>>’ in ‘std::cin.std::basic_istream<_CharT, _Traits>::operator>> [with _CharT = char, _Traits = std::char_traits<char>](((int&)(& first))) >> std::endl’