+ 3
Transportation
Can someone help with the transportation code in C++ please?
12 Respostas
0
Mustafa Mansour
Just one line of code
cout << 50 - passengers % 50;
Where passengers is input.
+ 6
Hi! what exactly was the problem? ask a specific question
+ 2
Oh, so you can do it in few 3-4 linesđ
The one user variable you need is an amount of passengers. If we are talking about the same task, your bus can accommodate 50 passangers. So, your formula gonna be: 50 - passengers % 50
Where the "passengers" is total amount of passangers, and "50" is amount of passengers that can contain the bus in full
+ 1
#include <iostream>
using namespace std;
int main() {
//your code goes here
int a=126;
int b=50;
int seats;
int p1;
int p2;
seats=(a-b);
p1=seats-b;
p2=b%p1;
cout<<"seats left empty :"<<p2<<endl;
return 0;
}
+ 1
thank you guys! much appreciation
0
Wdym about that? You want to take code from another language and remake it for c++?
0
No, he wants to solve the problem of lessons with passengers on the bus
0
Ouch đ
Then, Mustafa Mansour , show us your attempts or describe what exactly didn't you understand
0
thats what i did ( not really a good coder btw)
0
i get the answer 24, which is supposed to be the right answer but it doesnt give me any indication that my answer is right
0
I typed this code in transportation program in c++ but I am getting negative output instead of a positive one please clear me
#include <iostream>
using namespace std;
int main() {
int passenger;
int available;
int remseats;
cin>>passenger;
if(passenger<=50){
remseats=passenger-50;
cout<<remseats;
}
else{
remseats=passenger-50;
available=passenger-50;
cout<<available;
};
}
0
Drunken Troll first, for your calculations, you need to discard, cross out, separate the total number of passengers that can be taken away by fully filled buses... remember, that one bus can accommodate 50 passengers