delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/03/03/16:16:41

From: michelc AT jeeves DOT be DOT cut DOT this DOT tail (Michel Castelein)
Newsgroups: comp.os.msdos.djgpp,comp.lang.c
Subject: Re: trigonometry problem (math.h)
Date: Wed, 04 Mar 1998 03:39:29 GMT
Organization: UUNET Benelux (post does not reflect views of UUNET Benelux)
Lines: 44
Message-ID: <6dhira$l7i$1@xenon.inbe.net>
References: <34FC314E DOT A9B3F9D6 AT usa DOT net>
NNTP-Posting-Host: pool02a-194-7-47-12.uunet.be
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019