0

Why is this not working for all tests? Could anybody suggest me..this is working for only 1,2,5 tests for paint costs.

#include <stdio.h> #include<math.h> int main() { int colours,sum,tax; scanf("%d %d %d",&colours,&sum,&tax); sum=5*colours+40; tax=sum/10; sum=sum+tax; printf ("%d",sum); return 0; }

6th May 2020, 1:57 PM
Sanjana Gopavajjhula
Sanjana Gopavajjhula - avatar
1 Respuesta
+ 1
Since sum is int, and 10 is int, you get result of sum/10 as integer only, you miss fraction part so 1 of them should double of float.. So take as double or use 10.0.. Now take color as double,. Only one input is given so scanf("%lf", @color); is enough.. To store fraction part in tax, it should double or float.. The result in total sum should rounded up means ex: 10.4 to 11.0,.. Or 7.9 to 8.0. And finally print result as integer...
6th May 2020, 8:28 PM
Jayakrishna 🇮🇳