0

Halloween candy...Why it doesn't work???

#include <iostream> #include <cmath> using namespace std; int main() { int houses; cin>>houses; double c = 200/houses; cout<< ceil( c); return 0; } I used ceil () function to round up. but it passes just 1 test...what is the problem??

30th Jan 2020, 11:39 AM
Raziyeh
Raziyeh - avatar
2 Respuestas
+ 3
You have to cast 200 / houses to double before you assign it because you are dividing an int by another int. Try 200.0 / houses or (double)200 / houses.
30th Jan 2020, 11:47 AM
你知道規則,我也是
你知道規則,我也是 - avatar
0
Thank u 🌹🌹😊
30th Jan 2020, 11:53 AM
Raziyeh
Raziyeh - avatar