Write a program to calculate the estimated journey time of a train. The
program should request and read the distance in miles and the average
speed in miles per hour, and display the estimated journey time in hours
and minutes to the nearest minute.
Test your program with:
a) Distance = 1.01, speed = 1. [Result should be 1 hour & 1 minute.]
b) Distance = 1.005, speed = 1. [Result should be 1 hour & 0 minutes.]

here are my codes:

#include <stdio.h>
#include <stdlib.h>
int main()
{
    float dist, speed;
    float time;

    printf("Enter Distance in miles: ");
    scanf("%f", &dist);
    printf("Enter Speed in miles per hour: ");
    scanf("%f", &speed);

    time=dist/speed;

    printf("The estimated journey is %.2f", time);

    system("pause");
    return(0);
}

as in the question is said to display the time in hours and minutes! my problem here is i do not know how to do it any help? i think that the final should be "1 hour & 1 minute" display on the window

If time = 12.5 for example then the integral part is the number of hours, So here this would be12 hours. Multiply the fractional part by 60 to get the minutes. Here this would be 0.5 x 60 = 30 minutes. Hope this helps.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.