0
Halloween_Candy(Code_Coach_Problem)
I made a code to solve the halloween candy problem. It passed the first two tests but failed in the remaining 3 test cases. As they are hidden,I can't understand what's wrong with my code. My_code: #include <stdio.h> int main() { int houses; float a,b; scanf("%d", &houses); if(houses>=3){ a=(float)2/houses; b=(float)a*100; printf("%0.0f",b); } return 0; }
3 Antworten
+ 7
Output should be rounded up to the nearest integer.
#include <math.h>
...
printf("%0.0f",ceil(b))
+ 1
Ceil rounds float up to the next int.
0
Simba It worked!
But how did it worked!?
What is the use of ceil!?