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",°rees);
/*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);
}
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",°rees);
/*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);
}