- 10

Transportation program in c++ plz tell me

4th Dec 2020, 8:32 AM
Mohammed Shoheb
Mohammed Shoheb - avatar
14 Respuestas
+ 3
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!!
4th Dec 2020, 8:38 AM
Minho
Minho - avatar
+ 2
Kindly clarify for what you are asking for!
4th Dec 2020, 8:53 AM
Piyush
Piyush - avatar
+ 2
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. https://code.sololearn.com/cAsIKRZH3quK/?ref=app
16th Dec 2020, 12:40 PM
Lam Wei Li
Lam Wei Li - avatar
+ 1
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; }
30th Dec 2020, 10:52 PM
Caleb Nielsen
Caleb Nielsen - avatar
0
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;
16th Mar 2021, 1:59 PM
Soumik
- 1
#include <iostream> using namespace std; int main(){ // your code goes here int a, b, c, z; b = 50; cin>>c; // a = ? a = c % b; z = b - a; cout<<z<<endl; }
30th Oct 2021, 5:02 PM
Mujtaba Naqvi
Mujtaba Naqvi - avatar
- 2
#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
6th Mar 2021, 1:36 PM
Ronish Parmar
Ronish Parmar - avatar
- 2
#include <iostream> using namespace std; int main(){ // your code goes here int a, b, c, z; b = 50; cin>>c; // a = ? a = c % b; z = b - a; cout<<z<<endl; }
9th Jun 2022, 6:36 AM
Shilpa Asole
Shilpa Asole - avatar
- 3
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
16th Mar 2021, 4:54 PM
Benjamin Jürgens
Benjamin Jürgens - avatar
- 4
How
4th Dec 2020, 8:36 AM
Mohammed Shoheb
Mohammed Shoheb - avatar
- 5
This is not a free programming service. Don't be brazen.
4th Dec 2020, 8:47 AM
Benjamin Jürgens
Benjamin Jürgens - avatar
- 6
Plz write a program
4th Dec 2020, 8:37 AM
Mohammed Shoheb
Mohammed Shoheb - avatar