+ 3
Help in code coach "Halloween Candy"
can someone correct this code to solve the "Halloween candy" code coach problem?: #include <iostream> #include <cmath> using namespace std; int main() { int houses; cin>>houses; //your code goes here float a=(2.0*100)/houses; float b=fmod(a,1); if(b>=0.5){ cout<<a+1-b; }else{ cout<<a-b; } return 0; }
1 ответ
+ 3
You are asked to *round up* the result..
You are trying to *round* the result to nearest integer.
So Just apply ceil() function...