How come the input is 12 and the output is 38? i need to understand what it needs to do, not the code solution, if you please. | Sololearn: Learn to code for FREE!
¡Nuevo curso! ¡Todo programador debería aprender IA Generativa!
Prueba una lección gratuita
- 1

How come the input is 12 and the output is 38? i need to understand what it needs to do, not the code solution, if you please.

C++ First code project (Transportation)

16th Nov 2021, 7:18 PM
Elia Garas Motwade
Elia Garas Motwade - avatar
7 Respuestas
+ 1
Elia Garas Motwade my Friend you have to get the Logic before the coding: * let's say there is 162 people waiting in bus station . *First bus takes 50 passengers . //112 left *Second bus takes another 50 . //62 left *Third bus takes another 50 . //12 left In this case : Input == 162 Output == 50-12 == 38 There are 38 empty seats in the last bus . Use "%" : 162%50=12 50-12=38
17th Nov 2021, 12:42 PM
Zakaria AKTOUF
Zakaria AKTOUF - avatar
+ 4
Read hits there again carefully... The first bus will transport 50 passengers at once. leaving last bus will take all of the 12 passengers, having 50-12=38 seats left empty.
16th Nov 2021, 7:25 PM
Jayakrishna 🇮🇳
+ 2
Elia Garas Motwade it doesn't have to be 12 , it was just an example ( sample ) . They're using the sample to check if your code works . Check the comments on the practice you'll find help there .
17th Nov 2021, 11:29 AM
Zakaria AKTOUF
Zakaria AKTOUF - avatar
+ 1
That's because 12 seats are taken , 38 seats are free . The output is the number of free seats on the bus .
17th Nov 2021, 2:09 AM
Zakaria AKTOUF
Zakaria AKTOUF - avatar
+ 1
Still didn't get it, why the user input must be 12 not any other number !!
17th Nov 2021, 7:32 AM
Elia Garas Motwade
Elia Garas Motwade - avatar
+ 1
Input may be any integer.. (not only 12). For any input, you need to find empty seats.. n = int(input()) # n may be any integer ...(unless, if there already defined as 12 ,then only work with 12 ) Elia Garas Motwade
17th Nov 2021, 12:34 PM
Jayakrishna 🇮🇳
+ 1
AJ Zack Now i get it, thanks broo 👍👍
17th Nov 2021, 1:54 PM
Elia Garas Motwade
Elia Garas Motwade - avatar