+ 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 ответов
+ 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