Transportation | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1


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. Hint: The modulo operator % can help to determine the number of passengers for the last bus.

27th Jan 2022, 4:48 PM
A Rahman Mamnoon
A Rahman Mamnoon - avatar
3 Answers
+ 1
try this #include <iostream> using namespace std; int main() { //your code goes here int p; cin>>p; int rem=p%50; int seats=50-rem; cout<<seats; return 0; }
27th Jan 2022, 5:01 PM
Mohammad Matin Kateb
Mohammad Matin Kateb - avatar
+ 1
AB Rahman "Mamnoon" Your approach may works, but what if input is above 300? It's a practice about using% operator so simply cout<< ( 50 - passenger%50) ; works fine
27th Jan 2022, 5:10 PM
Jayakrishna 🇮🇳
? What Next? Are you tried anything? Pls Post your try...
27th Jan 2022, 4:51 PM
Jayakrishna 🇮🇳