ā€œPopsiclesā€ | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

ā€œPopsiclesā€

You have a box of popsicles and you want to give them all away to a group of brothers and sisters. If you have enough left in the box to give them each an even amount you should go for it! If not, they will fight over them, and you should eat them yourself later. Task Given the number of siblings that you are giving popsicles to, determine if you can give them each an even amount or if you shouldn't mention the popsicles at all. Input Format 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.

5th Mar 2021, 12:19 AM
TahitišŸŒCastillo
TahitišŸŒCastillo - avatar
3 Answers
+ 7
It's not necessary to use endl for taking inputs. cin>>a>>b; You need to close the if condition properly. if (a%b==0); You're missing another '}' before return 0. else{ cout<<"output "; } return 0; }
5th Mar 2021, 12:56 AM
Simba
Simba - avatar
+ 1
Simba , Thank you!!!
5th Mar 2021, 1:13 AM
TahitišŸŒCastillo
TahitišŸŒCastillo - avatar
0
#include <iostream> using namespace std; int main() { int siblings, popsicles; //take input cin >> siblings >> popsicles >> endl; if (popsicles%siblings) == 0 { cout << "give away"; } else { cout << "eat them yourself"; return 0; }
5th Mar 2021, 12:19 AM
TahitišŸŒCastillo
TahitišŸŒCastillo - avatar