HALLOWEEN CANDY | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

HALLOWEEN CANDY

Kindly check the Halloween candy Problem and my Solution to it. It passed only 2 test cases and failed the other 3. Please help me to improve my code so that it passes all 5 test cases https://sololearn.com/coach/4/?ref=app https://code.sololearn.com/cjp2sfvJIoE4/?ref=app

29th Apr 2021, 4:46 AM
SNEHEL
SNEHEL - avatar
3 Answers
+ 3
Try it in this way #include <iostream> using namespace std; int main() { float houses; float dollar; cin >> houses; //your code goes here { dollar = (((houses - (houses - 2))) / houses) * 100; if (dollar == (int)dollar) { cout << dollar; } else cout << (int)dollar + 1; } return 0; }
29th Apr 2021, 4:51 AM
Aysha
Aysha - avatar
+ 3
Most welcome SNEHEL
29th Apr 2021, 11:24 AM
Aysha
Aysha - avatar
+ 1
thanx it worked!
29th Apr 2021, 10:04 AM
SNEHEL
SNEHEL - avatar