- 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.

13th Apr 2021, 10:32 AM
k thirupathi rao
k thirupathi rao - avatar
6 Answers
+ 9
k thirupathi rao , please do not ask for a ready code here. it does not really help you to improve your coding skills and your problem solving abilities, when you don't do it by yourself. to get help from the community, please do a try by yourself first and put your code in playground. then link it here. thanks for your understanding!
13th Apr 2021, 11:13 AM
Lothar
Lothar - avatar
+ 3
k thirupathi rao 50 - passengers % 50
13th Apr 2021, 10:35 AM
A͢J
A͢J - avatar
+ 1
k thirupathi rao This is the program. Just take input as passengers and use this code to get output.
13th Apr 2021, 10:38 AM
A͢J
A͢J - avatar
+ 1
#include <iostream> using namespace std; int main() { int x,y,z,i; //x is the number of total passengers a bus can transport x=50; //y is the number of total passengers waiting in the bus station cin >> y; if (y<x); {i=x-y; } if (y>x); {z=y%x; //z is the number of passengers left i=x-z; } //seats left empty cout << i; return 0; }
18th Jun 2021, 7:27 AM
Abhisek Kar
Abhisek Kar - avatar
0
Please write a program
13th Apr 2021, 10:36 AM
k thirupathi rao
k thirupathi rao - avatar