- 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)
7 Answers
+ 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
+ 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.
+ 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 .
+ 1
That's because 12 seats are taken , 38 seats are free . The output is the number of free seats on the bus .
+ 1
Still didn't get it, why the user input must be 12 not any other number !!
+ 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
+ 1
AJ Zack
Now i get it, thanks broo đđ