Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

new to C and programming please help

Name: Anonymous 2011-11-20 3:18

I am doing this example from the book C all-in-one desk reference for dummies, the proper answer is suppose to be 34.64
but my answer is always 0.00 .
my os is linux mint 9, here is the code:

#include <stdio.h>
#include <math.h>

#define RAD 57.2957795

int main()
{
    double opposite,angle;
    float degrees,adjacent;

    puts("how tall is that tree?");
    printf("how far away is the tree in feet?");
    scanf("&f",&adjacent);
    __fpurge(stdin);
    printf("what angle is it to the tree top?");
    scanf("&f",&degrees);

  /*convert degrees to rads */

    angle = (double)degrees/RAD;

  /* get the tree height */

     opposite = tan(angle) * (double)adjacent;

     printf("that tree is %.2f feet tall.\n",opposite);
     return(0);
}

Name: Anonymous 2011-11-20 10:12

maybe but it was /prog/ that said it was as easy as getting a book and reading it til you understand it. i took up the challenge and dont regret it. like all things in life we are not born knowing how to do it til we understand the hows and whys or atleast thats what i believe. but since your a person who understands programming can you tell me the secret?

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List