+ 1

another way to do

#include <iostream> using namespace std; int main() { int siblings, popsicles; //take input cin>>siblings>>popsicles; //your code goes here if(popsicles % siblings==0){ cout<<"give away"; } else cout <<" eat them yourself "; return 0; }

5th Nov 2022, 11:11 PM
Akirito Emlz
Akirito Emlz - avatar
1 Answer
+ 2
Akirito Emlz your code looks very good. If you want something different you can substitute the modulo operator with a calculation: if ((popsicles/siblings)*siblings==popsicles) { ... Other than that you can reduce the code: #include <iostream> int main() { int siblings, popsicles; std::cin >> siblings >> popsicles; std::cout << (popsicles%siblings? "eat them yourself" : "give away"); return 0; }
6th Nov 2022, 1:27 AM
Brian
Brian - avatar