Answer to Question #219843 in C++ for ZAWAIAH BINTI MOHM

Question #219843

Write a function to calculate the distance a vehicle has traveled for a given time period

at a given speed. The distance travelled can be calculated from the following formula:

distance = speed * time period

For example, if a car travels at 110 km per hour for three hours, the distance travelled

is 330 km.


1
Expert's answer
2021-07-22T18:31:34-0400
#include <iostream>

using namespace std;

void distance(double time, double speed) {
    cout << "The distance is: " << speed*time << "km" << '\n';
}

int main()
{
    distance(3, 110);

    return 0;
}

Output:
The distance is: 330 km

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS