+ 2

This code is valid only for tesr case 1 z help me in this Fruit bowl code coach solution

#include <iostream> using namespace std; int main() { int fruit; //take input cin>>fruit; //your code goes here if(fruit%2==0){ int a=fruit/2; int b=fruit/2; int c=0; while(b%3==0){ ++c; b--; } cout<<c; } else{ cout<<"Enter even number"; } return 0; }

21st Oct 2021, 9:56 AM
Tanu Jain
6 Respostas
+ 2
The question is saying that the bowl has only even no. of fruits so no need of the first condition. Secondly, pies are made by using 3 apples only and not the other fruits, so division operation will be applied to fruits and corresponding result i.e., amount of apples will use a division again by 3 resulting in the total amount of pies.
21st Oct 2021, 1:39 PM
Surbhi Yadav
Surbhi Yadav - avatar
+ 2
Kindly share the problem link! Also try to avoid sharing code as paragraph, put your code in code bits and share the link here
21st Oct 2021, 10:05 AM
Saurabh
Saurabh - avatar
21st Oct 2021, 3:37 PM
Surbhi Yadav
Surbhi Yadav - avatar
0
Tanu Jain This challenge starts like this. int main() { int fruit, apples, pies; //take input cin>>fruit; //your code goes here Your code has corrupted the section prior to where you were supposed to put your code, so that makes it difficult to achieve a result. You don't need all the % bits, the int division will automatically get rid of any extras. Number of fruit / by 2 = apples Number of apples / by 3 = pies Just to repeat myself: int / int = int
21st Oct 2021, 10:38 AM
Rik Wittkopp
Rik Wittkopp - avatar
0
Surbhi Yadav Plz send me the code🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏
21st Oct 2021, 3:29 PM
Tanu Jain
0
Tanu Jain Yeah sure!
21st Oct 2021, 3:34 PM
Surbhi Yadav
Surbhi Yadav - avatar