0
Is this the correct way to use the ceil function here?
#include <stdio.h> #include <math.h> int main() { int houses; scanf("%d", &houses); double percentage; percentage=(100*2)/houses; int result= ceil(percentage); printf("%d\n",result); return 0; } If not, please correct the code..
2 odpowiedzi
+ 1
Instead of 100 * 2, make it 200, but don't forget .0
I mean it should be 200.0 / houses
Otherwise, when it is 200 / houses it will always return integer, because compiler will think you are dividing int by int.
0
Mustafa, Thank you❤