Site icon T4Tutorials.com

Find time, distance and speed in C++(C Plus Plus)

In this latest tutorial, we will cover the program to find the time, distance and speed in C++(C Plus Plus)

// Find time=distance/speed
#include <iostream>
using namespace std;
int main()
{
int dis,sp;
float t;
cout<<"Enter the distance: ";
cin>>dis;
cout<<"Enter the speed: ";
cin>>sp;
t=dis/sp;
cout<<"The time required is: "<<t<<endl;
}

 

Figure: Find time distance speed in C++(C Plus Plus)
Exit mobile version