Halloween Candy help in C | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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; }

29th Apr 2020, 6:02 AM
Epsilon ︻╦̵̵͇̿̿̿̿╤──
Epsilon ︻╦̵̵͇̿̿̿̿╤── - avatar
3 Answers
+ 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.
29th Apr 2020, 6:33 AM
Damyian G
Damyian G - avatar
+ 1
Thank you Damyian G, very cool!
29th Apr 2020, 1:18 PM
Epsilon ︻╦̵̵͇̿̿̿̿╤──
Epsilon ︻╦̵̵͇̿̿̿̿╤── - avatar
0
printf("%d", (int)ceil(c));
29th Apr 2020, 10:44 AM
Jayakrishna 🇮🇳