0
Paint costs in C
Hi all, I wrote this code in C that’s working for cases 1,2, and 5 but its not working for case 3 and 4. Can someone help? https://sololearn.com/coach/22/?ref=app #include <stdio.h> #include <math.h> int main() { int canvas_brush,color,total,tax; scanf("%d",&color); canvas_brush=40; tax=(canvas_brush+(color*5))*0.10; total=ceil(canvas_brush+(color*5)+tax); printf("%d",total); return 0; }
2 odpowiedzi
+ 4
Try changing the variables from int to float. It is likely the tax calculation is losing important fractional value.
+ 2
^That was the case. Thanks!