Sololearn C++ 'Transportation' problem solution and explanation.

Problem Explaination

The first bus will transport 50 passengers, leaving 126-50=76 in the station.

The next one will leave 76-50 = 26 in the statio thus, the last bus will take all of the 26 passengers, having 50-26=24 seats left empty.

Problem Hint

The modulo operator % can help to determine the number of passengers for the last bus.

Problem Solution

#include <iostream> using namespace std; int main() { int passenger, seats, filledseats, emptyseats; seats=50; cout << "Enter passengers amount" << endl; cin >> passenger; filledseats=passenger % seats; emptyseats = seats - filledseats; cout <<"Last bus filled seats" << endl << filledseats << endl; cout <<"Last bus emtpy seats " << endl<< emptyseats << endl; return 0; }