Im currently new to C++ and im currently trying to make a basic calculator, but i seem to get some errors which i cant figure out, i would really appreciate some help :)
you defined a variable as a character. and called it op for representing the input character that will represent the operation.
for getting it from the user you didn't use the same name.
you wrote cin >> operator. you must use the same name you called it. ie cin >> op; and you forgot the semicolon.
and about the loop, if it's a do {} while() loop, you forgot the do up before the braces. and you closed the braces of the loop body twice. and didn't close the main function
#include <iostream>
usingnamespace std;
int main()
{
char op;
int a;
int b;
int result;
do
{
cout << "Enter a number \n";
cin >> a;
cout << "Enter second number \n";
cin >> b;
cout << "Enter operator +,-,*,/:";
cin >> op;
if(op =='-') result = a - b;
if(op =='+') result = a + b;
if(op =='*') result = a * b;
if(op =='/') result = a / b;
cout << "Result: " << result;
}while (true);
return 0;
}
when declaring many variables of the same kind you could declare them all in one phrases.
i.e.
int a, b, result;
and you should better make the program start every new period of the loop in a new line. or even leave 2 or 3 lines by editing the last line in the loop