exapsy

Untitled

Apr 23rd, 2021
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.60 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. #define STEP 15
  5.  
  6. #define FROM_TIME 30
  7. #define TO_TIME 3 * 60
  8.  
  9. int scanVelocity() {
  10.     int v;
  11.     printf("Velocity: ");
  12.     scanf("%d", &v);
  13.     return v;
  14. }
  15.  
  16. int calculateDistance(int velocity, int time) { return velocity * time; }
  17.  
  18. void printDistanceTable(int velocity) {
  19.     printf("| DISTANCE | TIME |\n");
  20.     for (int time = FROM_TIME; time < TO_TIME; time += STEP) {
  21.         int distance = calculateDistance(velocity, time);
  22.         printf("| %d\t | %d\t |\n", distance, time);
  23.     }
  24. }
  25.  
  26. int main() {
  27.     int velocity = scanVelocity();
  28.     printDistanceTable(velocity);
  29.     return 0;
  30. }
  31.  
Advertisement
Add Comment
Please, Sign In to add comment