Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #define STEP 15
- #define FROM_TIME 30
- #define TO_TIME 3 * 60
- int scanVelocity() {
- int v;
- printf("Velocity: ");
- scanf("%d", &v);
- return v;
- }
- int calculateDistance(int velocity, int time) { return velocity * time; }
- void printDistanceTable(int velocity) {
- printf("| DISTANCE | TIME |\n");
- for (int time = FROM_TIME; time < TO_TIME; time += STEP) {
- int distance = calculateDistance(velocity, time);
- printf("| %d\t | %d\t |\n", distance, time);
- }
- }
- int main() {
- int velocity = scanVelocity();
- printDistanceTable(velocity);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment