#include <stdio.h>
int main() {
// Declare variables for speed, time, and distance
float speed, time, distance;
// Prompt the user to enter speed and time
printf("Enter the speed of the object (e.g., m/s or km/h): ");
scanf("%f", &speed); // Use %f for floating-point numbers
printf("Enter the time taken (e.g., seconds or hours): ");
scanf("%f", &time);
// Calculate the distance
distance = speed * time; // Formula: distance = speed * time
// Display the result
printf("The distance traveled by the object is: %.2f\n", distance); // %.2f formats to two decimal places
return 0;
}
Comments
Post a Comment