Help with this problem | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 1

Help with this problem

Two integer values, the first one represents the number of siblings, and the second one represents the number of popsicles that you have left in the box. Output Format A string that says 'give away' if you are giving them away, or 'eat them yourself' if you will be eating them yourself. Sample Input 3 9 Sample Output give away

18th Sep 2021, 6:00 AM
William Rosado
William Rosado - avatar
8 Answers
+ 2
if ( paletas% hermanas ==0)
18th Sep 2021, 6:06 AM
Simba
Simba - avatar
+ 2
If hermanas = 6 and paletas = 4, output should be "eat them yourself" since you can't evenly share them. But it gives you give away(6%2 ==0 && 4%2==0)
18th Sep 2021, 6:14 AM
Simba
Simba - avatar
+ 1
William Rosado As Simba has already shown, the expression: If the number of popsicles can be given to the siblings equally Can be expressed as: if(popsicles % siblings ==0) It is almost a direct translation of language into code
18th Sep 2021, 6:16 AM
Rik Wittkopp
Rik Wittkopp - avatar
+ 1
technically the expression% implies that if the amount entered can be divided into equal parts giving zero, is it correct?
18th Sep 2021, 6:19 AM
William Rosado
William Rosado - avatar
+ 1
William Rosado Yes! if you can divide a quantity into equal parts, then you will have zero remainder. 0 remainder means no arguments from your siblings
18th Sep 2021, 6:21 AM
Rik Wittkopp
Rik Wittkopp - avatar
+ 1
Thank You
18th Sep 2021, 6:22 AM
William Rosado
William Rosado - avatar
0
#include <iostream> using namespace std; main() { int paletas; int hermanas; //take input cin>>hermanas; cin>>paletas; if (hermanas %2==0 && paletas %2==0){ cout <<"give away"; } else { cout <<"eat them yourself"; } //your code goes here return 0; } This are mi code I pass 4 test but i fail in 1 of 5 , but i don't know why , and solo learn don't show me my error.
18th Sep 2021, 6:01 AM
William Rosado
William Rosado - avatar
0
Can you explain me , by PM , pls
18th Sep 2021, 6:07 AM
William Rosado
William Rosado - avatar