Problem: Billy is standing 150m away from a wind turbine. His eye level is 2m from the ground. If his angle of elevation is 25° to the top of the turbine, determine the height of the wind turbine using a C++ program.

Code: 
#include <iostream>
#include <cmath>
#define pi 3.14159
using namespace std;

int main(){
    float base, x, angle, el, height;

    cout << "Enter the distance from WT: ";
    cin >> base;


    cout <<"Enter the eye level from ground: ";
    cin >> el;

    cout << "Enter the angle of elevation: ";
    cin >> angle;

    x = base*tan(angle* pi/180);        //value of tan() should be converted in radians
    height = x+el;

    cout << "The height of the wind turbine is " << height << "m";
}

Output: 
Enter the distance from WT: 150
Enter the eye level from ground: 2
Enter the angle of elevation: 25
The height of the wind turbine is 71.9461m
Process returned 0 (0x0)   execution time : 6.815 s
Press any key to continue.

Previous Post Next Post