Calculate speed , distance and time | C ++ Program to calculate speed distance and time ; Function to calculate speed ; Function to calculate distance traveled ; Function to calculate time taken ; Driver function ; Calling function cal_speed ( ) ; Calling function cal_dis ( ) ; Calling function cal_time ( )
#include <iostream> NEW_LINE using namespace std ; double cal_speed ( double dist , double time ) { cout << " Distance ( km ) : " cout << " Time ( hr ) : " return dist / time ; } double cal_dis ( double speed , double time ) { cout << " Time ( hr ) : " cout << " Speed ( km / hr ) : " return speed * time ; } double cal_time ( double dist , double speed ) { cout << " Distance ( km ) : " cout << " Speed ( km / hr ) : " return speed * dist ; } int main ( ) { cout << " The calculated Speed ( km / hr ) is : " << cal_speed ( 45.9 , 2.0 ) << endl ; cout << " The calculated Distance ( km ) : " << cal_dis ( 62.9 , 2.5 ) << endl ; cout << " The calculated Time ( hr ) : " << cal_time ( 48.0 , 4.5 ) << endl ; return 0 ; }