Need help !!!!!!

This is a discussion on Need help !!!!!! within the C Programming forums, part of the General Programming Boards category; I NEED HELP WITH MY HOMEWORK< I JUST CAN GET THE RIGHT ANSWER!!! THANKS IN ADVANCE Problem Description Write a ...

  1. #1
    Registered User
    Join Date
    Feb 2011
    Posts
    39

    Question 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);

    printf("Enter Radians> ");
    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);
    }

  2. #2
    printf("Hello Cboard\n"); codeprada's Avatar
    Join Date
    Jan 2011
    Location
    In a little room at the back of your brain
    Posts
    68
    use %lf to input doubles

    Code:
     
    printf("Enter Distance> ");
    scanf("%lf", &Distance);
    
    printf("Enter Radians> ");
    scanf("%lf", &Theta);
    
    printf("Enter Velocity> ");
    scanf("%lf", &Velocity);

  3. #3
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,340
    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.
    << !! Posting Code? Read this First !! >>
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  4. #4
    Third Eye Babkockdood's Avatar
    Join Date
    Apr 2010
    Posts
    352
    Quote Originally Posted by Salem View Post
    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.
    << !! Posting Code? Read this First !! >>
    Pwned.
    Quote Originally Posted by The Jargon File
    Microsoft Windows - A thirty-two bit extension and graphical shell to a sixteen-bit patch to an eight-bit operating system originally coded for a four-bit microprocessor which was written by a two-bit company that can't stand one bit of competition.

Popular pages Recent additions subscribe to a feed

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21