- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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
- Related Articles
- Program to convert speed in km/hr to m/sec and vice versa in C++
- C++ Program to Convert Binary Number to Octal and vice-versa
- C++ Program to Convert Binary Number to Decimal and vice-versa
- C++ Program to convert Octal Number to Decimal and vice-versa
- Golang program to convert the arraylist into string and vice-versa
- Java Program to Convert the LinkedList into an Array and vice versa
- Java Program to Convert the ArrayList into a string and vice versa
- Convert string to DateTime and vice-versa in Python
- How to convert String to StringBuilder and vice versa Java?
- Java Program to Convert contents of a file to byte array and Vice-Versa
- Golang program to convert a linked list into an array and vice-versa
- C program to convert upper case to lower and vice versa by using string concepts
- C Program for LowerCase to UpperCase and vice-versa
- How to convert 54km/hr into m/s?
- How to convert an integer to hexadecimal and vice versa in C#?

Advertisements