fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <math.h>
  4.  
  5. /* Average velocity of plane = 529 miles per hour */
  6.  
  7. /* 1km = 0.621371 miles */
  8.  
  9. int main()
  10. {
  11. float distance, time;
  12. float velocity = 529;
  13. float km_to_miles = 0.621371;
  14. int hours, minutes;
  15.  
  16. printf("Enter the distance travelled by the aeroplane in kilometers:");
  17. scanf("%f", &distance);
  18.  
  19. distance = (distance)*(km_to_miles);
  20.  
  21. time = distance / velocity;
  22.  
  23. hours = time;
  24.  
  25. time = time - hours;
  26.  
  27. time = time*60;
  28.  
  29. minutes = round(time);
  30.  
  31.  
  32. if (minutes == 60) {
  33. hours++;
  34. minutes=0;
  35.  
  36. }
  37.  
  38.  
  39. printf("The aeroplane's flight time is %d hours and %d minutes.\n", hours, minutes);
  40. return 0;
  41. }
  42.  
  43.  
Success #stdin #stdout 0s 2172KB
stdin
Standard input is empty
stdout
Enter the distance travelled by the aeroplane in kilometers:The aeroplane's flight time is -2147483648 hours and -2147483648 minutes.