CJCoding With Joseph

Convert Kilometers to Miles

Write a function double toMiles(double km) that converts kilometers to miles by multiplying by 0.621371. Call it with toMiles(10.0) and print the result with exactly 2 decimal places:

6.21

Use <iomanip> fixed and setprecision(2).

Expected Output:

6.21
Topics:
Functions
Code Editor
1
Tab to indent ยท Ctrl+Enter to run ยท Ctrl+Space to expand shortcuts (cout, fori)

Your Output

Run your code to see the output here...

Test Cases

Run your code to see test case results.