0

Can someone explain to me the solution

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. Solution: #include <iostream> using namespace std;   int main() {     //your code goes here     int a,c,d;     c=50;     cin>>a;     if (a>c) {        d=a%c;        cout<<50-d;     }     if (a<c) {         d=c-a;         cout<<d;     }         return 0; }

6th Sep 2021, 10:51 AM
Bruce Daine M. Sison
Bruce Daine M. Sison - avatar
2 odpowiedzi
+ 7
Bruce Daine M. Sison 126 % 50 = 24 This means 24 people are available for the last bus, because each bus can take 50 people. 50 - 24 = 26 26 seats are available on the last bus because there are only 24 people left Turn this concept into code & you will resolve it
6th Sep 2021, 10:55 AM
Rik Wittkopp
Rik Wittkopp - avatar
+ 2
Looks like you wrote this solution in another compiler and pasted it here. It creates some invalid characters on code playground if you did it. So, you can delete each line and rewrite it again. It should work
6th Sep 2021, 2:50 PM
Simba
Simba - avatar