0

Can anyone help me to check what is going wrong? (C++)

The problem is : Transportation 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. Hint: The modulo operator % can help to determine the number of passengers for the last bus. Here is my code: #include <iostream> using namespace std; int main() { int a,b,x,y; cin >> a; cout << "Sample Input:\n" << a << endl; b=50; if ((a%b)==0) { cout << "No empyt seats left " << endl; } if ((a%b) !=0) { x = a%b; y = b-x; cout << "Sample Output:\n" << y << endl; } return 0; } The test show wrong?

28th May 2021, 3:53 PM
DAYU
DAYU - avatar
2 odpowiedzi
+ 1
Code coaches just needed output which specified in description, no extra charecters or terms to be displayed... use only cout<<y; //remove all other couts
28th May 2021, 3:59 PM
Jayakrishna 🇮🇳
+ 1
I get it correctly ! Thanks guys ! Appreciate for that !
28th May 2021, 4:09 PM
DAYU
DAYU - avatar