0
Can someone help
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.
8 ответов
+ 4
Hint: if you use the modulo operator, it will return the remainder. I.E. 126 % 50 = 26
You then just need to subtract this number from the total number of seats on a bus to find the number of remaining available seats on the last bus.
+ 1
Jeremiahgustusjunior
1. Get the input (cin) value as an int. Where you have 126 in your expression you should have the variable name for the input value.
2. Remove the quotes from around the variable y in the cout statement. "y" will output y as a String and not the value held by the variable y as intended.
+ 1
Dude that was very helpful .....fixed errors..thanks
0
Cool thanks
0
#include <iostream>
using namespace std;
int main() {
//your code goes here
int y;
y = 50-126%50;
cout <<"y"<<endl;
return 0;
}
0
Wats my bug there if I may ask