Write a C program to find the distance and the velocity of a freely falling obje
ID: 3792102 • Letter: W
Question
Write a C program to find the distance and the velocity of a freely falling object from given time and acceleration. Also, display error if negative or zero is entered and if alphabets are entered display error as "Invalid errors".
T, A: D, V
Given, t=time(measure in seconds)
d=distance(measured on meters)
v=final velocity(measure in meters per second)
a=constant acceleration(meausred in meters per second per second; 9.8 on earth,
1.6 on moon. 3.7 on mars)
All variables >0
formula:
2d=vt
v=at
2da=v^2
Explanation / Answer
#include <stdio.h>
int main(){
double time;// time
const double a = 9.8 / time;
printf("Time in seconds:");
scanf("%d",&time);
double distance = (a*pow(time,2))/2;
double velocity=(2*distance/time);
printf("Distance--> %d",distance);
printf("Velocity--> %d",velocity);
getch();
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.