Given the Length and Speed of the train and the time takes by the train to passes the bridge or tunnel, the task is to find the length of the bridge.
Input : length of train = 120 meters, Speed = 30 m/sec, time = 18 sec
Output : length of bridge = 420 meters.
Input : length of train = 130 meters, Speed = 25 m/sec, time = 21 sec
Output : length of bridge = 395 meters.
Let the length of the bridge be .
As it is known that Speed = Distance / Time
Total distance = (length of train + length of bridge)
=> Speed of train = (length of train + x) / Time.
=> x = (Speed of train * time) – Length of train.
length of bridge = (speed of train * time taken to cross bridge) – length of train.
Below is the implementation of the above approach:
Length of bridge = 420 meters
Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.
- Program to find the Speed of train as per speed of sound
- Find the length of the median of a Triangle if length of sides are given
- C program to find the length of a string
- Minimize number of cuts required to break N length stick into N unit length sticks
- Construct a string of length L such that each substring of length X has exactly Y distinct letters
- Length of longest subarray of length at least 2 with maximum GCD
- Program for focal length of a lens
- Length of the chord the circle if length of the another chord which is equally inclined through the diameter is given
- Program to determine focal length of a spherical mirror
- Find length of Diagonal of Hexagon
- Find the maximum length of the prefix
- Find length of period in decimal value of 1/n
- Find the length of factorial of a number in any given base
- Find a range of composite numbers of given length
- Find longest length number in a string
- Find length of longest Fibonacci like subsequence
- Find Nth even length palindromic number formed using digits X and Y
- Find the number of valid parentheses expressions of given length
- Find the count of numbers that can be formed using digits 3, 4 only and having length at max N.
- Find number of magical pairs of string of length L
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.