I am making a program that let's users enter velocity and angle and then program calculates the vertical and horizontal component and now i am trying to make the program also calculate time of flight (TOF). The equation is t=2*Vo*sin(ang)/g. but i am stuck on how to implement it. I have tried to implement it but i am not so successful.
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
void components(float Vo, float ang, float* outpVx, float* outpVy,float* X,float* Y, float a,float t)
{
t=0.1;
a=-9.81;
*outpVx=Vo*cos(ang);
*outpVy=Vo*sin(ang);
*X=*outpVx*t;
*Y=*outpVy*t+(0.5*a*(t*t));
}
void TOF(float Vo,float ang,float g,float t)
{
g=9.81;
main(Vo,ang);
t=(2*Vo*sin(ang))/g;
}
int main(void)
{
float Vo,ang;
float outVx=0.0;
float outVy=0.0;
float X;
float Y;
float t=0.1;
float a=-9.81;
float g= 9.81;
printf("\nEnter Velocity:\n");
scanf("%f",&Vo);
printf("\nEnter Angle:\n");
scanf("%f",&ang);
components(Vo,ang, &outVx, &outVy, &X, &Y,a,t);
printf("Horizontal \t Vertical\n");
printf("%f \t %f", X, Y);
TOF(t,g,Vo,ang);
printf("%f",t);
return 0;
}
some guidance would be much appreciated.