- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

# Program to find Length of Bridge using Speed and Length of Train in C++

In this problem, we are given the length (L) and speed (S) of the train along with the time taken by it to pass the bridge. Our task is to create a program to find Length of Bridge using Speed and Length of Train in C++.

## Problem Description

We need to find the length of the bride using the speed of the train, the time taken by it to cross the bridge, And the length of the train.

**Let’s take an example to understand the problem,**

**Input**: L = 310, S = 45m/sec , time = 12 sec

**Output**: 230 m

## Solution Approach

The whole train passes through the bridge at a speed of S in T. The time taken is for the train entering the bridge to the train leaving the bridge. So, the distance will be the length of train (L) + length of bridge(B).

Formulating it,

S*T = (L+B)

Finding the length of the bridge (B),

B = S*T - L

## Example

#include <iostream> using namespace std; int findBridgeLenght(int L, int S, int T) { int B = ( (S*T) - L); return B; } int main() { int L = 150, S = 45, T = 25; cout<<"The length of the bridge is "<<findBridgeLenght(L, S, T); return 0; }

## Output

The length of the bridge is 975

- Related Questions & Answers
- Program to find length of longest matrix path length in Python
- Program to find maximum length of k ribbons of same length in Python
- Program to find length of a list without using built-in length() function in Python
- Program to find minimum length of lossy Run-Length Encoding in Python
- Crest Speed, Average Speed & Schedule Speed of an Electric Train
- Python Program to Find the Length of a List Using Recursion
- Program to find length of shortest supersequence in Python
- C++ Program to Find the Length of a String
- C program to find the length of a string?
- C program to find the length of linked list
- Python Program to Find the Length of the Linked List using Recursion
- Program to find out the length of longest palindromic subsequence using Python
- Program to find length of longest possible stick in Python?
- Program to find length of longest balanced subsequence in Python
- Program to find length of longest anagram subsequence in Python