Question: Hello, I need help with the following C-program. I am not getting the desirable outputs. I need to get results from the Horizontal Distance(x), Vertical
Hello, I need help with the following C-program. I am not getting the desirable outputs. I need to get results from the Horizontal Distance(x), Vertical Distance(y), and Vertical Velocity(Vx) formulas to be shown in the table. I believe there might be some data missing in this line: printf("%6.2f %6.2f %6.2f %6.2f ", ti, x, y, Vy);
thanks!
#include #include #include #include #include int main() { float v, a, r, Vxo, Vyo, g, tof, t, Vx, x, y, Vy, ti; printf("Enter a velocity: "); scanf("%f", &v); printf("Enter an angle in degrees: "); scanf("%f", &a); printf("--- Input Information ----------------"); printf(" Initial Velocity Vo = %6.2f",v ); printf(" Angle in Degree = %6.2f" ,a ); printf(" --------------------------------------"); r = a * M_PI/180; printf(" Angle in radian = %6.2f", r ); Vxo = v * cos(r); printf(" Initial Horizontal Velocity = %6.2f", Vxo); Vyo = v * sin(r); printf(" Initial Vertical Velocity = %6.2f", Vyo); g = 9.80665; tof = (2 * v * sin(r))/g; printf(" Time of Flight = %6.2f", tof); printf(" Input a given time interval (ti): "); scanf("%f", &ti); printf(" ------------------------------------------------------------------------------------------ "); printf(" Time Horizontal Distance Vertical Distance Vertical Velocity "); ti = 0; while (ti <= 8.00) { x = Vx * ti; y = Vyo * t - (.5) * g * pow(t,2); Vy = Vyo - g * t; printf("%6.2f %6.2f %6.2f %6.2f ", ti, x, y, Vy); ti = ti + 0.50; } printf(" Press any key to exit the program ... "); getche(); }