Question #262347

An automobile travels at an average speed of 55 miles per hour for four hours. Draw a flowchart, write an algorithm and design a C++ program that computes and displays the distance driven, in miles that the car has travelled after 0.5, 1.0, 1.5 hours, and so on until the end of the trip.


Expert's answer

#include <iostream>

using namespace std;

int main()
{
    int speed = 55;
    double time[3] = {0.5, 1.0, 1.5};
    for (int i = 0; i < 3; i++) {
        cout << "Distance: " << speed*time[i] << '\n'; 
    }

    return 0;
}
LATEST TUTORIALS
APPROVED BY CLIENTS