0

Code coach popsicles challenge

//mycode: #include <stdio.h> int main() { int siblings, popsicles; scanf("%d", &siblings); scanf("%d", &popsicles); //your code goes here if (siblings && popsicles ==0){ printf("give away"); } else{ printf("eat them yourself"); } return 0; } My code fails in second step and I don't know what operators or functions should I use please someone give me a clue...

11th Oct 2025, 9:04 AM
Axxcii
Axxcii - avatar
12 Respuestas
+ 3
> You confused popsicles and siblings. We need the remaining popsicles, not the remaining siblings. Suppose siblings = 2 popsicles = 7 Compare: siblings % popsicles = 2 % 7 popsicles % siblings = 7 % 2 The order matters.
11th Oct 2025, 4:21 PM
Lisa
Lisa - avatar
+ 2
If the number is evenly divisible by the number of siblings, we are supposed to give the popsicles to them. Hence, we need to find out if popsicles / siblings is 0 (evenly divisible) or not. This is also called integer division or modulo or "division with remainders". We check if the remainder is 0 or not. In C, there is a dedicated modulo operator: %.
11th Oct 2025, 10:03 AM
Lisa
Lisa - avatar
+ 2
> In C, there is a dedicated modulo operator: %.
11th Oct 2025, 12:56 PM
Lisa
Lisa - avatar
+ 2
You confused popsicles and siblings. We need the remaining popsicles, not the remaining siblings.
11th Oct 2025, 1:07 PM
Lisa
Lisa - avatar
0
Lisa yes got some let me try
11th Oct 2025, 10:04 AM
Axxcii
Axxcii - avatar
0
if (siblings / popsicles ==0){ printf("give away"); } else{ printf("eat them yourself"); } return 0; } Can't get it till😕
11th Oct 2025, 12:51 PM
Axxcii
Axxcii - avatar
0
Yes if I use (siblings % popsicles==0) // Still gives error.. I'm missing something 😭
11th Oct 2025, 12:57 PM
Axxcii
Axxcii - avatar
0
Please can you level up your hint one more step please 🥺
11th Oct 2025, 1:00 PM
Axxcii
Axxcii - avatar
0
I know I've have find that popsi && siblings should have a condition where both variable should be able to divided by 2 but I'm weak in math po😢
11th Oct 2025, 1:02 PM
Axxcii
Axxcii - avatar
0
Lisa can you show me the code answer 🙂
11th Oct 2025, 4:07 PM
Axxcii
Axxcii - avatar
0
#include <stdio.h> int main() { int siblings, popsicles; scanf("%d %d", &siblings, &popsicles); //your code goes here if (siblings % popsicles ==0){ printf("give away"); } else{ printf("eat them yourself"); } return 0; } // Please help
11th Oct 2025, 4:11 PM
Axxcii
Axxcii - avatar
0
Lisa yeah thank you it's done ✅😅💝
11th Oct 2025, 4:38 PM
Axxcii
Axxcii - avatar