Hi,
I need to write a program that has the user input a command such as ADD (adds two numbers), SUB(subtracts two numbers), DIV( divides), MUL(multiplies) and then input the two numbers. The user is asked to input all three things at one time. Here is the code.
Code:
#include<stdio.h>
#include<math.h>
int performance(char[], int, int);
int main()
{
int one;
int two;
char com[3];
int FI;
printf("Enter Instruction:");
scanf(" %3s %d %d", &com, &one, &two);
FI = performance( com, one, two);
printf("the answer is %d\n", FI);
return(0);
}
int performance(char A[], int B, int C)
{
int final;
char ADD;
char SUB;
char DIV;
char MUL;
if(A[3] == ADD)
{
printf("%d", final);
}
if(A[3] == SUB)
{
final = B - C;
}
if(A[3] == DIV)
{
final = B / C;
}
if(A[3] == MUL)
{
final = B*C;
}
return(final);
}
I am not getting the right answers. I think it has something to do with my if statements.
please help.
THANKS