Code Coach - Fruit Bowl | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
+ 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 Respostas
+ 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