Using Math Functions

Coordinate geometry.

Determine the distance between point (x1, y1) and point (x2, y2), and assign the result to pointsDistance. The calculation is:

Distance=(x2x1)^2+(y2y1)^2

You may declare additional variables.
Ex: For points (1.0, 2.0) and (1.0, 5.0), pointsDistance is 3.0.

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

int main(void) {
 double x1 = 1.0;
 double y1 = 2.0;
 double x2 = 1.0;
 double y2 = 5.0;
 double pointsDistance = 0.0;

pointsDistance = sqrt(pow(x2 - x1, 2) + pow(y2 - y1, 2));

printf("Points distance: %lf\n", pointsDistance);

return 0;
}

Tree height.

Simple geometry can compute the height of an object from the object’s shadow length and shadow angle using the formula: tan(angleElevation) = treeHeight / shadowLength.
1. Using simple algebra, rearrange that equation to solve for treeHeight.
2. Write a statement to assign treeHeight with the height calculated from an expression using angleElevation and shadowLength.
#include <stdio.h>
#include <math.h>

int main(void) {
 double treeHeight;
 double shadowLength;
 double angleElevation;

angleElevation = 0.11693706; // 0.11693706 radians = 6.7 degrees
 shadowLength = 17.5;

treeHeight = tan( angleElevation ) * ( shadowLength );

printf("Tree height: %lf\n", treeHeight);

return 0;
}