Erster Commit
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
// --> FPa
|
||||
// --> PPS
|
||||
|
||||
// A --> B
|
||||
// distance [KM]
|
||||
// speed [KM/H]
|
||||
|
||||
|
||||
int main(void) {
|
||||
|
||||
float distance;
|
||||
int speed;
|
||||
float time;
|
||||
int hours;
|
||||
int minutes;
|
||||
|
||||
printf("Travel time calculator.\n");
|
||||
|
||||
printf("Distance: ");
|
||||
scanf("%f",&distance);
|
||||
printf("=> %.2f km\n", distance);
|
||||
|
||||
printf("Speed: ");
|
||||
scanf("%d",&speed);
|
||||
printf("=> %d km/h\n", speed);
|
||||
|
||||
time = distance / (float)speed;
|
||||
|
||||
printf("\nTime to go [dec]: %.2f\n", time);
|
||||
|
||||
hours = (int) time;
|
||||
minutes = (time - hours) * 60;
|
||||
|
||||
printf("Drive time : %d h and %d min\n", hours, minutes);
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user