0
Halloween candy codecoach!
#include <stdio.h> #include<math.h> int main() { int houses; scanf("%d", &houses); float b=(200.0/houses); printf("%.0f",ceil(b)); //your code goes here return 0; } Is there any other ways to do it?
4 Réponses
+ 3
#include <stdio.h>
int main() {
int houses;
scanf("%d", &houses);
int perc = (int)(((2.0/(double)houses)*100.0) + 0.99);
printf("%d", perc);
return 0;
}
+ 2
Hi Dan Delgado
If 200 were to be used, the result would be the integer part of the division 200/houses, as both terms are integer. But using 200.0 the compiler automatically cast the division as a floating point operation.
+ 1
Oh that makes sense, thanks for the explaining, now i get it. :)
0
why did you put 200.0 instead of 200?