0

Help me in completing this project

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.

1st Apr 2021, 11:49 AM
Prakash Kumar Suthar
Prakash Kumar Suthar - avatar
10 ответов
+ 3
I got u😊😊..so here's my final code and it works😇..... #include <iostream> using namespace std; int main() { int n,l,r; /* n=total passengers at station */ cin>>n; cout<<n<<endl; l=n%50; /* r=empty seats in last bus*/ r=50-l; cout<<r; return 0; }
1st Apr 2021, 12:53 PM
Prakash Kumar Suthar
Prakash Kumar Suthar - avatar
+ 2
#include <iostream> using namespace std; int main() { int n,l,r; cin>>n; cout<<"total passengers at station: "<<n; l=n%50; r=50-l; cout <<"\nempty seats in last bus: "<<r; return 0; } I did this..is it right?
1st Apr 2021, 11:54 AM
Prakash Kumar Suthar
Prakash Kumar Suthar - avatar
+ 1
Post your attempt please, that wouldn't be "helping you complete" the project. We would just be doing the project for you
1st Apr 2021, 11:52 AM
Slick
Slick - avatar
+ 1
I dont know cpp but yeah, the formula looks just fine. You got the total amount, got the remainder when modded with 50, and subtracted the remainder from the total number of seats. You should have your answer. print em out and see if your answer makes sense Prakash Kumar Suthar EDIT: Just checked your code out and it works fine. Just cut out that extra text, Sololearn usually only looks for the minimum in it's output
1st Apr 2021, 11:59 AM
Slick
Slick - avatar
0
About which extra text u are saying to cut?
1st Apr 2021, 12:26 PM
Prakash Kumar Suthar
Prakash Kumar Suthar - avatar
0
Check the sample that input is 126 and output is 24 only.. Remaining all text in output is not needed...
1st Apr 2021, 12:39 PM
Jayakrishna 🇮🇳
0
total passengers... and empty seats... in challenges, it shouldn't have anything else than the correct output printed. No prompts for user, no extra text to make the output make more sense, none of that. Just print the answer
1st Apr 2021, 12:45 PM
Slick
Slick - avatar
0
Awesome man, keep it up!
1st Apr 2021, 12:53 PM
Slick
Slick - avatar
0
Prakash Kumar Suthar ur final answer looks good.. but if i were u i wouldnt use that many variables.. especially in c++ with all this memory management.. instead do : int p; cin >> p; p %= 50; cout << 50 - p;
2nd Apr 2021, 2:06 PM
Γεωργιος Τανανης
Γεωργιος Τανανης - avatar
0
int a; cin >> a; cout << 50 - a % 50; // An easier approach
3rd Apr 2021, 4:17 AM
Calvin Thomas
Calvin Thomas - avatar