Program that asks for hour the trip started and the hour the trip ended and the distance traveled. Then outputs the average speed of the trip.

#include<iostream.h>
void main()
{
int h1,h2,h,t;
float s,d;
cout<<"Enter starting time";
cin>>h1;
cout<<"Enter ending time";
cin>>h2;
h=h2-h1;
if (h<0)
{
   t=h+24;
  }
else
  {
    t=h;
   }
cout<<"\nEnter Distance";
cin>>d;
s=d/t;
cout<<"Average speed= "<<s;
}

Comments

Popular posts from this blog

How to root?

Why you should root your phone?