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 8:50

thanks anon for the save. its amazing how one's eyes skips over these things when you've already told yourself that you copied something correctly. also sorry for blaming the book for my mistake. i finally got the same answer as the book when i made the correction. I was just about to give up and leave this problem alone.

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