What's wrong with my logic | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

What's wrong with my logic

If I give 3 and 9 out will be give away same as if I give 10 20 also say give away but output showing eat them yourself why? #include <stdio.h> int main() { int siblings, popsicles; scanf("%d", &siblings); scanf("%d", &popsicles); //your code goes here siblings = siblings % popsicles; if(siblings ==0){ printf("give away"); } else{ printf("eat them yourself"); } return 0; }

17th Mar 2020, 11:27 AM
Vek
Vek - avatar
2 Answers
+ 5
It should be popsicles % siblings. Make this change and it should work.
17th Mar 2020, 11:32 AM
Avinesh
Avinesh - avatar
+ 2
Thanks bro I didn't notice that
17th Mar 2020, 11:38 AM
Vek
Vek - avatar