Abood F.

asked • 04/16/18

C Program Question

The height of an object thrown upward with a velocity v is given by
h(t)=vt-0.5gt^2
where t is time in sec and g is 9.81 m/s2. Write a C program to compute the height of the object at an interval of 0.1 s. Stop the computation when the object reaches the maximum height at time t=v/g. The program should read in the value of the velocity v and display the maximum height.
 
I already tried this: 
#include <stdio.h>
main(){

float h,t,v,g=9.81,maxH=0,maxT;

h=v*t-0.5*g*pow(t,2);

for(t=0;t<(v/g);t=t+0.1){

printf("Enter the value of v :\n");
scanf("%f", &v);


if(t>maxT)
t=maxT;

}


printf("\n\nThe Largest height is %f",h);
}

 
but still not working
 

1 Expert Answer

By:

Andy C. answered • 10/14/18

Tutor
4.9 (27)

Math/Physics Tutor

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.