Trying to write out a simple C Calculator script, using only the basic +, -, /, *. I have the following but not sure why it's not printing correctly. Any experienced C users out there?
#include<stdio.h>
#include<stdlib.h>
int main (void)
{
//introduce vars
double number1, number2, result;
char symbol; //the operator *, -, +, /
//allow user interaction
printf("Enter your formula \n");
scanf("%f %c %f", &number1, &symbol, &number2);
switch (symbol) {
case '+':
result = number1 + number2;
break;
default:
printf("something else happened i am not aware of");
break;
}
getchar();
return 0;
}
Why is the result not being printed? Am I doing something wrong here,
result = number1 + number2;