Write a C++ program that inputs the distance traveled and the speed of vehicle. It calculates the tine required to reach the destination and displays it.

 #include<iostream>

using namespace std;

int main()

{

double distance, time, speed;

cout<<"Enter the distance traveled in miles: ";

cin>>distance;

cout<<"Enter the speed of vehicle (mph): ";

cin>>speed;

time = distance/speed;

cout<<"Time required to reach destination: "<<time<<"hours."<<endl;

}

OUTPUT

Enter the distance traveled in miles: 100

Enter the speed of vehicle (mph): 10

Time required to reach destination: 10hours.


1 comment: