What's wrong in my code ?? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

What's wrong in my code ??

code C++ bugs: There are 126 passengers which wanna take the Bus. One bus has 50 places. How much buses are needed and how much places will stay free ...??? include <iostream> using namespace std; int main() { //your code goes here int pass; int pl; int sum; cin >> pass; cin >> pl; sum = pass % pl; cout << "Free bus places: " << sum << endl; return 0; }

5th Sep 2022, 1:04 PM
K1auDIa KaDaM0UR0
K1auDIa KaDaM0UR0 - avatar
4 Answers
+ 3
Thank u so much guys🙏🙏 I have really not understood that code. 😂 That's like I am 🤷🏻‍♀️
5th Sep 2022, 2:04 PM
K1auDIa KaDaM0UR0
K1auDIa KaDaM0UR0 - avatar
+ 2
126%50 = 26 is filled seats. Then empty seats are 50-26=24 Between if it code coach task then output only what is asked. No more extra or less characters..
5th Sep 2022, 1:31 PM
Jayakrishna 🇮🇳
+ 2
#include <iostream> using namespace std; int main() { //your code goes here int passenger=0,seat=0; cin>>passenger; seat=50-(passenger%50); cout<<seat; return 0; } You should not to take free places as input, only takes passengers and reminder of the division of passengers by capacity of the bus(50) ,then subtract from capacity of the bus(50).
6th Sep 2022, 6:47 AM
‎Kasem Almaleh
‎Kasem Almaleh - avatar
+ 1
K1auDIa we don't search for the remainder (which is the actual passengers in the last travel), but how much places will stay free (which is the capacity of the bus minus how much passengers left in that last trip)
5th Sep 2022, 1:56 PM
Amine Laaboudi
Amine Laaboudi - avatar