Code Coach - Fruit Bowl | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Code Coach - Fruit Bowl

Hello, I’m a beginner and I’m facing some issues. I’m only getting 2 out of 5 test cases right. Below is my code: #include <iostream> #include <math.h> using namespace std; int main() { double fruit, NoOfApples, NoOfPies; //take input cin>>fruit; //your code goes here if(fruit>=6){ NoOfApples = 0.5*fruit; NoOfPies = NoOfApples/3; cout<<ceil(NoOfPies); } else{ cout<<0; } }

30th Dec 2019, 8:02 AM
Danyal Ahmed
Danyal Ahmed - avatar
3 Answers
+ 6
Use integer instead of double (input and output is an integer). Remove ceil. Just print NoOfApples.
30th Dec 2019, 8:12 AM
Denise Roßberg
Denise Roßberg - avatar
+ 2
Danyal Ahmed Your welcome.
30th Dec 2019, 8:16 AM
Denise Roßberg
Denise Roßberg - avatar
+ 1
It worked perfectly! Thank you so much Denise!! 👍🏻🙏🏻
30th Dec 2019, 8:16 AM
Danyal Ahmed
Danyal Ahmed - avatar