I appreciate any help that I can get:
Write a program that takes as input an arithmetic expression and verifies if it is correct. The user will input the expression in the following format:
operator num1 num2 num3
The program should now check if:
num1 operator num2 = num3
If it is correct the program should print:
num1 operator num2 = num3
If it is not correct the program should print:
num1 operator num2 != num3
I did it without using functions but now I'm trying to test them out
What's wrong with the code?
Code:
#include <iostream>
using namespace std;
void user ()
int output()
int main ()
{
char op;
int x, y, z ;
user ()
output ()
return 0;
}
user ()
{
char op;
int x, y, z;
cout << "Enter an arithmetic Expression:" ;
cin >> op >> x >> y >> z ;
return;
}
output ()
{
char op;
int x, y, z ;
if (op = '+' &&
x + y == z)
cout << x << "+" << y << "==" << z <<endl;
else if ( op == '-' &&
x - y == z)
cout << x << "-" << y << "==" << z <<endl;
else if ( op == '*' &&
x * y == z)
cout << x << "*" << y << "==" << z << endl;
else if ( op == '/' &&
x / y == z)
cout << x << "/" << y <<"="<< z << endl;
else if ( op == '%' &&
x % y == z)
cout << x << "%" << y << "==" << z << endl;
else if ( op == '+' &&
x + y != z)
cout << x << "+" << y << "!=" << z << endl;
else if ( op = '-' &&
x - y != z)
cout << x << "-" << y << "!=" << z << endl;
else if ( op = '*' &&
x * y != z)
cout << x << "*" << y << "!=" << z << endl;
x / y != z
else if ( op = '/' &&
x / y != z)
cout << x << "/" << y << "!=" << z << endl;
else if ( op = '%' &&
x % y != z)
cout << x << "%" << y << "!=" << z << endl;
else
cout << "You are an idiot. This operator clearly does not exist. Try again, and do better" << endl;
return int ;
}