- 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
8 Respuestas
+ 2
if ( paletas% hermanas ==0)
+ 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)
+ 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
+ 1
technically the expression% implies that if the amount entered can be divided into equal parts giving zero, is it correct?
+ 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
+ 1
Thank You
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.
0
Can you explain me , by PM , pls