# Need help !!!!!!

• 02-10-2011
123456tacos
Need help !!!!!!
I NEED HELP WITH MY HOMEWORK< I JUST CAN GET THE RIGHT ANSWER!!! :(
THANKS IN ADVANCE :)
Problem Description

Write a program that computes the duration of a projectile’s flight and its height above the ground when it reaches the target. As part of your solution, write and call a function that displays instructions to the program user.

DATA REQUIREMENTS

Program Constant
G 32.17 /* gravitational constant */

Program Input
double Theta /* input – angle (radians) of elevation */
double Distance /* input – distance (ft) to target */
double Velocity /* input – projectile velocity (ft/sec) */

Program Output
double Time /* output – time(sec) of flight */
double Height /* output – height at impact */

Relevant Formula

time= distance/ velocity*cos(theta)

height= velocity * sin(theta) * time - g* time^2 / 2

this is what i have:
_--------------------------------------------------------------
#include <stdio.h>
#define Grav 32.17 /* gravitational constant */
#include <math.h> /*cos definition*/
#define PI 3.14159265

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*/

printf("Enter Distance> ");
scanf("%f", &Distance);

scanf("%f", &Theta);

printf("Enter Velocity> ");
scanf("%f", &Velocity);

Time = Distance / (Velocity * cos(Theta*PI/180.0) ) ;

Height = (Velocity *sin(Theta*PI/180.0)*Time) - ( Grav*(Time* Time) );

printf("The time of flight is %.3f seconds.\n", Time);
printf("The height at impact is %.3f feets.\n", Height);

system("pause");

return (0);
}
• 02-10-2011
use %lf to input doubles

Code:

``` printf("Enter Distance> "); scanf("%lf", &Distance); printf("Enter Radians> "); scanf("%lf", &Theta); printf("Enter Velocity> "); scanf("%lf", &Velocity);```
• 02-10-2011
Salem
You mean "help" such as picking a decent thread title
How To Ask Questions The Smart Way

Or "help" reading the forum rules
C Board - Announcements in Forum : C Programming

Or even "help" on posting code formatted so that people would want to read it.
• 02-10-2011
Babkockdood
Quote:

Originally Posted by Salem
You mean "help" such as picking a decent thread title
How To Ask Questions The Smart Way

Or "help" reading the forum rules
C Board - Announcements in Forum : C Programming

Or even "help" on posting code formatted so that people would want to read it.