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 Answers
+ 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