88.9k views
14 votes
Write a program to convert kilometers/hr to miles/hr. The program should produce a table of 10 conversions, starting at 60 km/hr and incremented by 5 km/hr. The display should have appropriate headings and list each km/hr and its equivalent miles/hr value. Use the relationship that 1 kilometer = 0.6241 miles. Implement this program using the FOR loop. Sample output is given below: write a c++ programe Page 1 of 2 I KM per hour Miles per hour 60 37.4460 65 40.5665 70 43.6870 46.8075 80 49.9288 85 53.0485 90 56.1690 95 59.2895 100 62.4100 105 65.5305​

1 Answer

3 votes

Answer:

#include <iostream>

using namespace std;

int main()

{

float speed_in_km_per_hr = 60;

// Output table head

cout << "km/hr miles/hr." << endl;

for (int i = 0; i < 10; i++)

{

// Convert KM/hr to miles/hr

float speed_in_miles_per_hr = speed_in_km_per_hr * 0.6241;

// Output speeds

cout << speed_in_km_per_hr << " " << speed_in_miles_per_hr << endl;

// Increase by 5

speed_in_km_per_hr = speed_in_km_per_hr + 5;

}

return 0;

}

Step-by-step explanation:

User Amit Vikram Singh
by
3.2k points