Transportation program in c++ plz tell me | Sololearn: Learn to code for FREE!


Transportation program in c++ plz tell me


12/4/2020 8:32:57 AM

Mohammed Shoheb

12 Answers

New Answer


Kindly clarify for what you are asking for!


Hii, SoloLearn has already given you the explanation about the problem. "The first bus will transport 50 passengers, leaving 126-50=76 in the station. The next one will leave 76-50 = 26 in the station, thus, the last bus will take all of the 26 passengers, having 50-26=24 seats left empty." They even provide this hint. "The modulo operator % can help to determine the number of passengers for the last bus." For further assistance please link your code. Thanks!!


A simple three lines of code implementation. First, you use the modulus function to find the remainder, which are the passengers on the last bus. Then, to find the empty seats, you use bus capacity minus away the last passengers.


I have written the code but how do get the input our return the output??????? Here is my code: int Passengers; cin >> Passengers; int EmptySeats = 126; EmptySeats -= Passengers % 50 cout<< EmptySeats<<endl;


I'll charge 200 INR. My rates are cheaper. Others may charge higher. Paytm accepted. DM me your Paytm information.


You can always do it the long way like I did. #include <iostream> using namespace std; int main() { const int buscapacity = 50; int waitingpassengers; int remainingpassengers; int seatsleft; cin >> waitingpassengers; if (waitingpassengers > 50) { do { remainingpassengers = waitingpassengers - buscapacity; waitingpassengers = remainingpassengers; if (remainingpassengers <= 50) { seatsleft = buscapacity - remainingpassengers; } } while (remainingpassengers > 50); } else { seatsleft = buscapacity - waitingpassengers; } cout << seatsleft; return 0; }


This is not a free programming service. Don't be brazen.


Soumik You get input from cin into the variable Passengers. For the example that is 126. Do your calculations with the variable Passengers. Be aware that 126 is only an example. Don't use fixed values from examples or test cases in your code, they are provided from input (cin). Repeat that chapter from the course if you need, to understand the concept


#include <iostream> using namespace std; int main() { //your code goes here int c,how; cin>>how; if(how>50) { how=how%50; } c=50-how; cout<<c; return 0; } easy


Include operations with % operator. Ez pz.



Plz write a program