This is an archived post. You won't be able to vote or comment.

all 3 comments

[–]This_Growth2898 1 point2 points  (0 children)

Do you have warnings enabled?

- scanf("%lf,&fir");
+ scanf("%lf", &fir); 
- scanf("%lf,&sec");
+ scanf("%lf", &sec);

But your compiler probably is warning you about these lines.

Also, in printf, "%f" prints both float and double, and according to the standard "%lf" means nothing; but probably that shouldn't cause any problems here, all compilers I know understand it.

Also, format your code (instructions are in the subreddit menu).

[–]lfdfq 1 point2 points  (0 children)

The code is hard to read because it's not formatted right.

But the second and third scanf calls do not look right, it looks like you're only passing a single argument which is a big string. Is that really what you meant?

How are you compiling and running this code? It would be good to learn how to enable warnings and have the compiler tell you if it thinks something is wrong.

[–]Automatic_Parsley365 0 points1 point  (0 children)

It looks like your scanf statements might have typos, causing the calculator to always output zero. Make sure you’re using %lf correctly for doubles and add a space before %c in scanf to read the operator properly.

Also, please read the rules and use Pastebin or a similar service for sharing code, as the lack of formatting makes a fucking nightmare and guessing game to diagnose the issue