0

Can someone help me with Popsicle problem with a c++ program

29th Apr 2020, 7:59 PM
Hadeed Tarar
Hadeed Tarar - avatar
9 Respostas
29th Apr 2020, 8:16 PM
! Bad Coder
! Bad Coder - avatar
+ 1
Here is the code in simple language. #include <iostream> using namespace std; int main() { int siblings, popsicles; //take input cin>>siblings>>popsicles; if (popsicles /siblings && popsicles % siblings == 0) { cout << " give away"; } else { cout << " eat them yourself " ; } return 0; }
1st May 2020, 11:13 AM
Kaustubh Shah
Kaustubh Shah - avatar
29th Apr 2020, 8:26 PM
Hadeed Tarar
Hadeed Tarar - avatar
29th Apr 2020, 8:26 PM
! Bad Coder
! Bad Coder - avatar
29th Apr 2020, 8:31 PM
Hadeed Tarar
Hadeed Tarar - avatar
0
Hadeed Tarar it's a link of popsicles question you must save code after writing it.
29th Apr 2020, 8:33 PM
! Bad Coder
! Bad Coder - avatar
29th Apr 2020, 8:44 PM
Hadeed Tarar
Hadeed Tarar - avatar
29th Apr 2020, 8:54 PM
Hadeed Tarar
Hadeed Tarar - avatar
0
Here is my code i think its foolproof #include <iostream> using namespace std; int main() { int p,s,m,c2; cin>>s; cin>>p; m = p%s; c2 = (p/s)*s; if (m==0||c2==p && p<s ){ cout<<"give away"; } else { cout<<"eat them yourself"; } return 0; }
7th Jan 2021, 4:38 PM
Umer Shahbaz
Umer Shahbaz - avatar