I'm currently learning about top-down programming in C in my class and I somehow can't really get the hang of it.
I have been trying to learn it by this programming exercise where you have to calculate when someone should leave depending on their arrival time (and speed in km/hr and distance in km), but I have done something very, very wrong since the output is somewhere around four million - always.
I'm using the book Problem Solving and Program Design in C and the relevant chapter is 3.5. Can anyone tell me what I did wrong? Also can someone explain how formal parameters works in a ELI5 kind of way?
#include <stdio.h>
#define MINUTES_IN_HOUR 60
int find_dprt_time(int diffhrs, int diffmin, int arvl_time, int trvl_time);
double find_trvl_time(int trvl_time, int distance, int speed, double result);
int main()
{
     double distance;
     int time,
         speed,
         diffmin,
         diffhrs;
     printf("Enter the time you need to arrive in military time:\n");
     scanf("%d",&time);
     printf("Enter the distance to your destination in kilometers:\n");
     scanf("%lf",&distance);
     printf("Enter the speed you plan to average in km/hr:\n");
     scanf("%d",&speed);
     printf("Your departure time is %d%d.\n",diffhrs,diffmin);
     return 0;
}
int find_dprt_time(int diffhrs, int diffmin, int arvl_time, int trvl_time)
{
     diffhrs = arvl_time / 100 - trvl_time / 100;
     diffmin = arvl_time % 100 - trvl_time % 100;
     return (diffhrs, diffmin);
}
double find_trvl_time(int trvl_time, int distance, int speed, double result)
{
     result = distance / speed;
     trvl_time = MINUTES_IN_HOUR * result;
     return (trvl_time);
}
 
     
     
    