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; }

25th Sep 2023, 7:17 AM
2 Answers
+ 4
Try changing the variables from int to float. It is likely the tax calculation is losing important fractional value.
25th Sep 2023, 8:36 AM
Brian - avatar
+ 2
^That was the case. Thanks!
25th Sep 2023, 8:58 AM