title: getting wrong values for time and height for projectile motion
body: <p>I'm writing a program in C that finds the time of flight and height at impact of a projectile and my program is compiling, but it's coming out with the wrong values for the solutions. Any idea what I might be doing wrong?</p>
  
  <pre><code>/*
  *Finds final time and height of a projectile when it reaches the target
  */
  #include &lt;stdio.h&gt; /* printf, scanf definitions */
  #include &lt;math.h&gt; /* cos definition */
  #define G 32.17 /* gravitational constant */
  
  int
  main(void)
  {
      double theta; /* input - angle(radians)of elevation */
      double distance; /* input - distance(ft)to target */
      double velocity; /* input - projectile velocity(ft/sec) */
  
      double time; /* output - time(sec)of flight */
      double height; /* output - height at impact */
  
      /* Opening explanation to user */
      printf("This program computes the duration of a projectile's flight and its height above the ground when it reaches the target. To use this program, enter the angle, the distance, and the velocity after each of the prompts.\n\n");
  
      /* Get angle, distance, velocity. */
      printf("Enter the angle of elevation in radians:");
      scanf("%f", &amp;theta );
      printf("Enter the distance to target in feet:");
      scanf("%f", &amp;distance );
      printf("Enter the projectile velocity in ft/sec:");
      scanf("%f", &amp;velocity );
  
      /* Get time of flight */
      time = distance / (velocity * cos(theta));
  
      /*Get height at impact */
      height = velocity * sin(theta) * time - ( (G * time*time) / 2.0 );
  
      /* Display time of flight */
      printf("The time of flight is %fs seconds.\n", time);
  
      /* Display height at impact */
      printf("The height at impact is %fm feet.\n", height);
  
      system("pause");
  
      return (0);
  }
  </code></pre>