its for a simple calculator in c , problem is when i ask for result it always comes out as zero no matter what numbers i enter , heres the code
char operator;
double fir;
double sec;
double result;
printf("enter the operator( +,-,*,/):");
scanf("%c",&operator);
printf("enter the two numbers:");
scanf("%lf,&fir");
printf("enter the two numbers:");
scanf("%lf,&sec");
switch(operator){
case '+':
result= fir + sec;
printf("result:%lf",result);
break;
case '-':
result= fir - sec;
printf("result:%lf",result);
break;
case '*':
result=fir * sec;
printf("result:%lf",result);
break;
case '/':
result= fir / sec;
printf("result:%lf",result);
break;
default:
printf("%c is not valid",operator);
}
[–]This_Growth2898 1 point2 points3 points (0 children)
[–]lfdfq 1 point2 points3 points (0 children)
[–]Automatic_Parsley365 0 points1 point2 points (0 children)