0
Please what is wrong with this code. It is as if the if condition is not read but only the else statement.
#include <iostream> using namespace std; int main() { int siblings, popsicles; //take input cin>>siblings>>popsicles; //your code goes here if (popsicles/siblings == 1){ cout <<"give away" << endl; if (popsicles/siblings == 2){ cout <<"give away" << endl; if (popsicles/siblings == 3){ cout << "give away" << endl; } } } else { cout << "eat them yourself" << endl; } return 0; }
1 ответ
+ 1
Your code outputs "give away" If both inputs same. Otherwise by else part.
What your inner if conditions do? Nothing. It's always false condition.
When popsicles/siblings == 1 then how it will be next equal to 2, or 3?
Among 3 siblings, 9 popsicles are evenly distributable. Think.
But 3 siblings, 10 popsicles not evenly distributable.. Task is to find how this?
use modula operator.