0

Code coach problem-

https://www.sololearn.com/coach/22?ref=app This is my solution - #include <stdio.h> int main() { int col_n; scanf("%d", &col_n); int cost = 40 + col_n *5 + ((40 + col_n*5)*10)/100; printf("%d\n", cost); return 0; } The result section is showing two failed cases(case 3, 4) Please guide me.

20th Sep 2020, 10:23 AM
Harshit Nema
Harshit Nema - avatar
6 Respuestas
+ 2
Because you have to rounded up to the nearest whole number. For example: if the answer is 88.32 You have to give output 89. You are using int instead of double .That's why I guess your answer is not right.
20th Sep 2020, 10:35 AM
The future is now thanks to science
The future is now thanks to science - avatar
+ 2
Spirit yes that's the trick .I just gave you a hint but I can give you the answer which is against in sololearn rules .Best of luck.
20th Sep 2020, 10:44 AM
The future is now thanks to science
The future is now thanks to science - avatar
+ 2
Okay I am giving you some suggestion .I think you understand you have to round the decimal number to the next number .So you can use google to find how to round up double .I hope you understand . Also use printf("%0.0lf) for 0 decimal .
20th Sep 2020, 10:49 AM
The future is now thanks to science
The future is now thanks to science - avatar
0
Samsil Arefeen but declaring cost as a double variable causing failed cases too. better if you elaborate it further.
20th Sep 2020, 10:40 AM
Harshit Nema
Harshit Nema - avatar
0
Samsil Arefeen but your hint is of no good for me.
20th Sep 2020, 10:46 AM
Harshit Nema
Harshit Nema - avatar
0
Okay
20th Sep 2020, 10:51 AM
Harshit Nema
Harshit Nema - avatar