# C++ Program to Convert Km/hr to miles/hr and vice versa

If input is in km/hr convert it to miles/hr else input will be in miles/hr convert it to km/hr. There are formulas that can be used for this conversion.

Conversion Formulas −

1 kilo-metre = 0.621371 miles
1 miles = 1.60934 Kilo-meter

## Example

Input-: kmph= 50.00
Mph = 10.00
Output-: speed in m/ph is 31.07
speed in km/ph is 16.0934

## Algorithm

Start
Step 1 -> Declare function to convert km/ph to m/ph
double km_mph(double km)
return 0.6214 * km
step 2 -> Declare function to convert m/ph to km/ph
double m_km(double m_ph)
return m_ph * 1.60934
step 3 -> In main()
declare variable as double kmph = 50 and double mph = 10
print km_mph(kmph)
print m_km(mph)
Stop

## Example

#include <bits/stdc++.h>
using namespace std;
// convert km/ph to m/ph
double km_mph(double km){
return 0.6214 * km;
}
//convert mph to kmph
double m_km(double m_ph){
return m_ph * 1.60934;
}
int main(){
double kmph = 50.00;
double mph = 10.00;
cout << "speed in m/ph is " << km_mph(kmph) << endl;
cout << "speed in km/ph is " << m_km(mph);
return 0;
}

## Output

speed in m/ph is 31.07
speed in km/ph is 16.0934