- 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

# Find speed of man from speed of stream and ratio of time with up and down streams in C++

In this problem, we are given two values S and N denoting the speed of stream in Km/h and ratio of time with up and down streams. Our task is to Find speed of man from the speed of stream and ratio of time with up and down streams.

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

## Input

S = 5, N = 2

## Output

15

## Solution Approach

A simple solution to the problem is by using the mathematical formula for the rowing problems. So, let’s see how the formula will work −

speed of man = x km/h speed of stream = S km/h speed of man downstream i.e. with stream = (x+S) km/h speed of man upstream i.e. against stream = (x-S) km/h Time to travel the distance downstream = T Time to travel the distance upstream = n*T Distance travelled upstream = (x - S)*n*T Distance travelled upstream = (x + S)*T As both the distances are same, (x + S) * T = (x - S)*n*T x + S = nx - nS s + nS = nx - x s*(n + 1) = x(n - 1)

$$x=\frac{S*(S+1)}{(S-1)}$$

**Program to illustrate the working of our solution,**

## Example

#include <iostream> using namespace std; float calcManSpeed(float S, int n) { return ( S * (n + 1) / (n - 1) ); } int main() { float S = 12; int n = 3; cout<<"The speed of man is "<<calcManSpeed(S, n)<<" km/hr"; return 0; }

## Output

The speed of man is 24 km/hr

- Related Questions & Answers
- Speed and Speed Regulation of DC motor
- Speed Time Curve of Electrical Traction System
- Crest Speed, Average Speed & Schedule Speed of an Electric Train
- Relationship between Speed and Frequency of Alternator
- Program to find Length of Bridge using Speed and Length of Train in C++
- Speed Control of Induction Motor
- Methods of Starting and Controlling the Speed of DC Traction Motors
- Ways To Speed Up Your Android Phone
- Synchronous Speed and Slip of a 3-Phase Induction Motor
- Electric Traction: Buck and Boost Method of Speed Control of Traction Motors
- Ward Leonard Method of Speed Control
- How to speed up SELECT DISTINCT in MySQL
- How to speed up $group phase in aggregation?
- Electric Traction: Quadrilateral Speed Time Curve
- Electric Traction: Trapezoidal Speed Time Curve

Advertisements