+ 4

Help me to solve this....only hint can also work

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.

16th Dec 2021, 8:40 AM
Hafsa batool
20 Respuestas
+ 6
I see. You can use directly share button from your code bits =) Anyway, may I know what is the purpose of the ing variable? Also one small note: if sub is modulus 50 of p, then using modulus on sub won't change its value as the value is already smaller than 50 =)
16th Dec 2021, 9:09 AM
Krysto Foxik 🐥
Krysto Foxik 🐥 - avatar
+ 9
The math behind it is W - waiting passengers, input T - max passengers per transport, 50 O - output, how many empty seats will last bus have We can use modulus on the waiting passengers, by this we will receive amount of passengers who will be using the last bus: W%T, and now we only need to know how many empty seats will the last bus have. We can put this together and: O=T-(W%T) should be our result =)
16th Dec 2021, 9:12 AM
Krysto Foxik 🐥
Krysto Foxik 🐥 - avatar
+ 3
Sure, take your time! =)
16th Dec 2021, 9:13 AM
Krysto Foxik 🐥
Krysto Foxik 🐥 - avatar
+ 3
Awesome, I'm glad! You're welcome =)
16th Dec 2021, 12:39 PM
Krysto Foxik 🐥
Krysto Foxik 🐥 - avatar
+ 3
Using % here will get the last no. Of persons standing N then less it from total 50 😊🌻💙 #include <iostream> using namespace std; int main() { //your code goes here int waiting; cin>>waiting; int last; last=waiting%50; cout<<50-last; return 0; }
17th Dec 2021, 9:42 AM
Ashish Sharma
Ashish Sharma - avatar
+ 2
#include <iostream> using namespace std; int main() { int a; cin>>a; int b=50; int c=a%b; int d=b-c; cout<<d<<endl; return 0; }
17th Dec 2021, 8:35 PM
Umair lehri
+ 1
Heya, please tell me your thoughts first so I can give you a hint based on that =)
16th Dec 2021, 8:52 AM
Krysto Foxik 🐥
Krysto Foxik 🐥 - avatar
+ 1
I see, can you please link your code here? I'm sure you're not far from the solution =)
16th Dec 2021, 9:04 AM
Krysto Foxik 🐥
Krysto Foxik 🐥 - avatar
+ 1
Ing is to count the remaining seats in bus....let me try it once again
16th Dec 2021, 9:13 AM
Hafsa batool
+ 1
It really worked thanku thanku thanku sooo much
16th Dec 2021, 9:18 AM
Hafsa batool
+ 1
If I remember well, you have to reach specific level to be able to send messages
16th Dec 2021, 12:39 PM
Krysto Foxik 🐥
Krysto Foxik 🐥 - avatar
+ 1
Oh right....... that's why I am not able to reply your message
16th Dec 2021, 12:41 PM
Hafsa batool
0
I have used modulus%....but still it doesn't work
16th Dec 2021, 9:03 AM
Hafsa batool
0
#include <iostream> using namespace std; int main() { //your code goes here int p, sub,rem,ing,gut; cin>>p; sub=p%50; rem=sub%50; ing=50%rem; p-50; cout<<50%p; return 0; }
16th Dec 2021, 9:06 AM
Hafsa batool
0
I have done this..... don't mind variables
16th Dec 2021, 9:06 AM
Hafsa batool
0
One more thing.......i can't message anyone because it shows that my account is not activated......but i have already activated it....what should i do.......can you help a little more?
16th Dec 2021, 9:20 AM
Hafsa batool
- 1
guys check out my codeing and I'm asking to look for the one that has 50 lines
17th Dec 2021, 10:42 PM
chill pillows
chill pillows - avatar
- 1
waiting=int(input()) remainingSeat = waiting%50 print (50-remainingSeat)
18th Dec 2021, 7:58 AM
Pradeep Bhaydiya
- 1
Psngr=input() Psngr2=int(psngr/50) Psngr3=50-(psngr-psngr2*50)
18th Dec 2021, 8:04 AM
Hasan Zakaria Tahhan
Hasan Zakaria Tahhan - avatar
- 1
Alternative a --> number of passengers at the bus station. a%50 you get number of passengers left at the bus station. 50 -(a%50) You will the number of empty seats of the last bus after taking the rest of the left passengers. int b = 50 - (a%50); cout << b;
18th Dec 2021, 8:32 AM
ShadowCipher
ShadowCipher - avatar