Write a C program to display a table of values for side B si

Write a C++ program to display a table of values for side B, side H, angle a (in degrees) and alpha (in degrees) for the right triangle shown. Use a for loop to calculate H, alpha and beta as side B from 2 m to 20 m in 2 m increments. The output should be a table of values for B, H, alpha and beta similar to the one shown below (no lines are required). Use 0 digits after the decimal point for B, 3 digits after the decimal point for H, and 2 digits after the decimal point for alpha, and beta. Turn in a printout of the program and a printout of the results. The table should be nicely aligned.

Solution

#include<iostream>

#include<cmath>

using namespace std;

int main()

{

cout<<\". B(m) \\t H(m) alpha. Beta)\";

for(int i=2;i<=20;i=i+2)

{

disp(i);

}

return 0;

}

void disp(int r)

{

double a=10.0;

double b=double(r);

double alpha=atan((a/b)*(180/3.14));

double beta=atan((b/a)*(180/3.14));

double h=a/sin(alpha);

cout<<\"\ \"<<h<<\"\\t\"<<alpha<<\"\\t\"<<beta;

}

 Write a C++ program to display a table of values for side B, side H, angle a (in degrees) and alpha (in degrees) for the right triangle shown. Use a for loop t

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site