Need help here | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 6

Need help here

You are making a program for a bus service. A bus can transport 50 passengers at once. Given the number of passengers waiting in the bus station as input, you need to calculate and output how many empty seats the last bus will have. Sample Input: 126 Sample Output: 24 Explanation: The first bus will transport 50 passengers, leaving 126-50=76 in the station. The next one will leave 26 in the station, thus, the last bus will take all of the 26 passengers, having 50-26=24 seats left empty.

21st Nov 2020, 9:22 PM
Emmy
5 Answers
+ 2
How about this? int solution(int num) { int cap = 50; int last = num%cap; return (cap-last); }
21st Nov 2020, 9:35 PM
boonga
boonga - avatar
+ 1
It doesn't work because it's not printing anything.
21st Nov 2020, 9:39 PM
Davide
Davide - avatar
- 1
Thanks But I tried same its not matching
21st Nov 2020, 9:37 PM
Emmy
- 1
@boonga...in your suggestion...you've called you function int main...apart from that..it works.
21st Nov 2020, 9:57 PM
rodwynnejones
rodwynnejones - avatar
- 1
You have to read input from cin and write output to cout
21st Nov 2020, 10:35 PM
Benjamin Jürgens
Benjamin Jürgens - avatar