I am trying to run this simple calculator code, and i don't know what's the problem with running this code.
After i enter the two operands (Num1 & Num2), the program automatically jumps to the switch default message, i have trying to check same codes over the internet and they look exactly the same...
Can someone please point what am i doing wrong ? (Running on visual studio 2017) Thanks !
int main() {
double Num1, Num2;
char operator;
printf("Enter first number:\n");
scanf("%lf", &Num1);
printf("Enter second number:\n");
scanf("%lf", &Num2);
printf("Enter operator: + or - ");
scanf("%c", &operator);
switch(operator)
{
case '+':
printf("%.1lf + %.1lf = %.1lf", Num1, Num2, Num1 + Num2);
break;
case '-':
printf("%.1lf - %.1lf = %.1lf", Num1, Num2, Num1 - Num2);
break;
default:
printf("Operator is not correct");
}
return 0;
}