Answer to Question #250695 in C++ for Shabo

Question #250695
A passenger train travels at a speed of 72 km/h. A man on the passenger train observes a
goods train travelling at a speed of 54 km/h in the opposite direction. If the good train passes him in X
seconds, write a C++ function to find the length of the goods train
1
Expert's answer
2021-10-13T02:00:16-0400
#include <iostream>
using namespace std;
int main(){
    int relative_speed = 72 - 54;
    float distance;
    cout<<"Enter number of seconds taken to pass the train: ";
    int x; cin>>x;
    cout<<"Length of the good train: "<<(float) relative_speed*1000/3600 * x<<" meters.\n";
    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS