+ 5

The below code used in code coach for cost of paints. my out put is same as result output but it not executed why?

#include <stdio.h> int main() { int n,num,money,tax,brushes_canvas=40; printf("enter number of colours\n"); scanf("%d",&n); num=n*5+brushes_canvas; tax=num/10; money=tax+num; printf("money required=%d",money); return 0; }

31st Jan 2022, 4:21 PM
ARAVIND DUDE
ARAVIND DUDE - avatar
3 Respostas
+ 5
//You have to round the result as in description mentioned: #include<stdio.h> #include<math.h> int main() { float paints; scanf("%f",&paints); float cost=round((paints*5+40)*11/10); printf("%.f",cost); }
31st Jan 2022, 5:26 PM
JaScript
JaScript - avatar
+ 2
Thanks a lot for ur suggestion JaScript 😊..
31st Jan 2022, 5:33 PM
ARAVIND DUDE
ARAVIND DUDE - avatar
+ 1
the code seems to be fine. you may typecast tax: tax = (int)(num/10); sometimes the "/" operator may cause trouble to integers. just an idea but it might not make any difference anyway.
31st Jan 2022, 4:52 PM
Mario Paes
Mario Paes - avatar