Question is given fruit number should be even. Half of it is apples and half banana. Takes 3 apples to make one pie. I | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Question is given fruit number should be even. Half of it is apples and half banana. Takes 3 apples to make one pie. I

This is my code below which asks input as number of fruits and number of pies as output. My code fails 3 out of 5 test conditions. Please help!!! #include <stdio.h> int b(int c); int main() { int fruit; int a; scanf("%d", &fruit); if(fruit>=6 && fruit%2==0) {a=b(fruit); printf("%d",a);} else{ printf("0");} return 0; } int b(int c) {int apples; int pies; apples=c/2; pies=apples/3; return(pies); }

16th Nov 2020, 7:17 AM
Sohel Kumar Samantaray
Sohel Kumar Samantaray - avatar
1 Answer
+ 5
You can write the code in this manner #include <stdio.h> int main() { int fruit,apple,pies; scanf("%d", &fruit); //your code goes here apple = fruit/2; pies = apple/3; printf("%d",pies); return 0; }
16th Nov 2020, 8:01 AM
Aysha
Aysha - avatar