Help in code coach "Halloween Candy" | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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; }

13th Jul 2023, 1:28 AM
Amine Amllal
Amine Amllal - avatar
1 Answer
+ 3
You are asked to *round up* the result.. You are trying to *round* the result to nearest integer. So Just apply ceil() function...
13th Jul 2023, 10:14 AM
Jayakrishna 🇮🇳