So I'm trying to make a simple calculator, I have a general idea but need tips. So far I have this but it's not working properly, once you enter something into scanf if just exits the program without showing me a result. I know later I'll have to throw in a loop, but for now i just want it to work once through.
Code:
#include <stdio.h>
#include <stdlib.h>
int main()
{
double result, x;
int op;
result=0.0;
printf("%f \n", result);
scanf("%d %lf", op, x);
if (op=='+')
{
result=result+x;
printf("result is: %f:", result);
}
else if (op=='-')
{
result=result-x;
printf("result is: %f:", result);
}
else if (op=='*')
{
result=result*x;
printf("result is: %f:", result);
}
else if (op=='/')
{
result=result/x;
printf("result is: %f:", result);
}
}