- 3
Hey guys how can I solve this
You will get the question inside
17 Answers
+ 3
where is your try?
+ 2
don't mark your own answer as the best ^^
+ 2
if we provide you the code without your own try, you will never learn anything ;)
+ 1
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.
Here is the question
+ 1
technically, it's an answer to your question ;)
you must share your coding attempt in order to get helped ^^
+ 1
ok :D
you must give a generic solution, working with any input (assume that all input are valid), and only output final result...
+ 1
the task ask for computing how many peoples will be in the last bus.
each bus can charge 50 persons
you need to compute the rest of integer division of total number of persons by total place in one bus: this give you how many place left in last bus...
then you should output total place in one bus minus place left in last bus:
int passengers;
cin >> passengers;
int left = passengers % 50
cout << 50 - left;
+ 1
excuse me:
you should only output how many place are left in last bus:
cout << left;
0
Ok that was not my answer that's my question
0
int main()
{
int x = 126 - 50;
cout << x << endl;
int y = 76 - 50;
cout << y << endl;
int z = 50 % 24;
cout << z;
}
Here it's but am just a beginner ok
0
Can you make it more clear
0
the task should give you prefilled code with input get from 'cin'
use the variable wich store input to compute your solution ;)
0
Ok I will try
0
you're almost on right way:
you need to use % operator, but not exactly as you do ;)
0
But how please give me directly the code
0
I was try many times but I can't get the correct code but for the first time give me the code and you can give me another question like that and 100% I will do the next question I mean if you are volunteer
0
Ok thanks a lot