+ 1

adding input to conversion

I've tried to combine the above formula with input, and succeeded in having no errors, but the output only says "no output"? #include <stdio.h> int main() { float average; int total; int count; scanf("%d", "%d", &total, &count); average = (float) total / count; printf("%4.2f", average); /* No errors but I receive "no output" */ return 0; }

5th Jun 2019, 12:50 PM
Ryan Stewart
4 Answers
+ 7
I tried your code and it seems that it will show the output if you put &total and &count in different scanf i.e : scanf("%d",&total); scanf("%d",&count);
5th Jun 2019, 12:57 PM
Uni
Uni - avatar
+ 5
You can do it on 1 line but you shouldn't separate the format with a , you can concatenate it. scanf("%d%d", &total, &count); should work.
5th Jun 2019, 1:05 PM
Dennis
Dennis - avatar
+ 2
Won't be the last time where 1 character/word will cost hours of debugging time. :)
5th Jun 2019, 3:01 PM
Dennis
Dennis - avatar
+ 1
Thanks for the help, go figure one comma ruined the whole thing!
5th Jun 2019, 3:00 PM
Ryan Stewart