+ 4
Halloween Candy help in C
When I test this, I get the right integer except it also puts decimals. The first case expected output is 67 and my answer is 67.00000 Here is my attempt tho #include <stdio.h> #include <math.h> int main() { int houses; scanf("%d", &houses); //your code goes here float c = 200.0/houses; printf("%f", ceil(c)); return 0; }
3 ответов
+ 1
If you want to exclude the decimals for floating point types you can change the printf format specifier to "%.0f" and it will read as if it was an integer.
+ 1
Thank you Damyian G, very cool!
0
printf("%d", (int)ceil(c));