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); }
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;
}