J123654 (1) I started learning c++ not a long time ago and i cannot complete one task, more specifically I can't find remnant. What am I doing wrong? Btw excuse me for bad English, it's not my first language and I was the one to translate the task. Thank you. John has n amount of balloons. He decided to share them with friends equally. k amount of balloons exploded . The rest John divided with d amount of friends. If there was any ballons left after division, John took them. How many balloons every single friend got and how many ballons John got? Check yourself with: If n = 77, d = 7 and k = 3, then every single friend got = 9 balloons, and John got 11 balloons. #include <iostream> #include <cmath> using namespace std; int main () { int n; //amount of balloons int m; //amount of balloons after explosions int k; //amount of explosions int d; //amount of friends int h; //amount of people to divide it with int k7, k6; int u; //1 cout << "write amount of balloons: "; cin >> n; cout << "write amount of explosions: "; cin >> k; cout << "write amount of friends: "; cin >> d; u = 1; m = n - k; h = d + 1; k7 = m / h; k6 = k7 + k1; // amount of balloons John got cout << "ballons :" << endl; cout << " 1 friend got ------> " << k7 << endl; cout << " John got ----->" << k6 << endl; return 0; } |
|
|
10 4 Program ended with exit code: 0 |
|
|
Each friend got 9 balloons. John got 11 balloons. |