Problem 07

author
By Supreme2023-02-23
Problem Statement :
Write a C program to find out distance travelled by the equation d = vt + at^2
Code:

#include <stdio.h>

int main()
{

// 7. Write a C program to find out distance travelled by the equation d = vt + at^2

printf("\t\tDistance Calculation");
printf("\n=======================================================");

float d, v, t, a;

printf("\n\n Enter The Velocity (m/s) : ");
scanf("%f", &v);

printf("\n Enter The Time periode (s) : ");
scanf("%f", &t);

printf("\n Enter The Acceleration (m/(s^2)): ");
scanf("%f", &a);

d = (v * t) + (a * t * t);

printf("\n_______________________________________________________");
printf("\n\n Distance Travelled By The Object Is : %.2f Meters", d);

printf("\n\n Formula Used d = vt + at^2");
printf("\n_______________________________________________________\n\n");
return 0;
}

Description :
  • This C program calculates the distance travelled by an object using the equation d = vt + 1/2at^2, where d is the distance travelled, v is the initial velocity, t is the time period, and a is the acceleration.
  • The program first prompts the user to enter the values for velocity, time period, and acceleration using printf statements. It then takes the user inputs using the scanf function.
  • Next, the program calculates the distance travelled using the formula and assigns it to the variable d.
  • Finally, the program prints the calculated distance and the formula used for the calculation using printf statements and returns 0 to indicate successful completion of the program.
Output Image:
Output-image

© Copyright 2022. All right reserved, GTU Coder.