Mail Archives: djgpp/1998/03/03/16:16:41
Jesse Meyer <jesse-meyer AT usa DOT net> wrote:
>I am writing some code to determine the vertical velocity of a
>projectile.
>The physics equation is voy = x (units/second) * sin(angle)
>I want to design a program that will calculate this given the inital
>velocity (x) and the angle.
>I am using DJGPP v2.01 and RHIDE 1.4
>This is basically a programming question because I am a begginer and all
>the books I read don't go into using Trig with C.
#include <stdio.h> /* define printf() and scanf() */
#include <math.h> /* define M_PI and sin() */
int main(void)
{
double x, angle, voy;
printf("initial velocity (units/second) = ???\n");
scanf("%lf", &x);
printf("angle (degrees) = ???\n");
scanf("%lf", &angle);
angle = angle * M_PI / 180; /* angle in radians) */
voy = x * sin(angle);
printf("vertical velocity = %f\n", voy);
return 0;
}
Hope you will pass your exam..
Regards,
Michel
Michel Castelein, OS/390 (MVS) System Engineer & Education Consultant
E-mail MichelC AT Jeeves DOT be Home page http://www.club.innet.be/~pub00543/
Company: JEEVES CONSULTING N.V. (phone +32-2-2516650 / fax +32-2-2525755)
- Raw text -