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

C++

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.

18th Oct 2021, 2:47 PM
Mando
Mando - avatar
4 Answers
+ 1
Mando you are doing arithmetical mistakes Look into it and write code again by yourself https://code.sololearn.com/cQQ7X0fy7fwd/?ref=app
18th Oct 2021, 2:52 PM
Saurabh
Saurabh - avatar
+ 2
Wow, thanks i was complicating the problem.
18th Oct 2021, 2:54 PM
Mando
Mando - avatar
+ 1
#include <iostream> using namespace std; int main() { double bus = 50; int people; cin >> people; if (people>=bus){ cout << people / bus << endl; } return 0; }
18th Oct 2021, 2:47 PM
Mando
Mando - avatar
+ 1
Mando if you satisfied with my answer then you can mark is as the best answer! Thanks! edit:- Glad you got it
18th Oct 2021, 4:43 PM
Saurabh
Saurabh - avatar