Remainder task

Hello. So I need to do this task for school, this program runs for me but I get wrong answers( 10 and 4 instead of 9 and 11). It might b not the program error, maybe its just me who doesnt know math well. Help. Here's the task: John has 'n' balloons.With his friend he decided to blow up those balloons,but 'k' of them exploded.
John shared the remaining ballons with his 'd' friends equally. If after sharing all the balloons equally,there were some left, then John took them. How many balloons 'm' every friend received and how many of them were left for John? Check: when n = 77, k = 3 and d
= 7, then every friend received 9 balloons, John got the remaining 11.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
  int main(){



cout<<"how many ballons were there?"<<endl;
cin>>n;
cout<<"how many of them exploded?"<<endl;
cin>>k;
cout<<"how many friends were there?"<<endl;
cin>>d;

m=(n-k)/d;
cout<<"every friend got :"<<m<<endl;
a=(n-m)%d;
cout<<"remain for john:"<<a<<endl;


return 0;
}
closed account (48T7M4Gy)
John plus 7 friends = 8 equal shares of 9 plus remainder (74-72=2) for John.

So 9 for friends and 11 for John. Tricky!
Thank you!
Topic archived. No new replies allowed.