Answer to Question #146565 in C++ for usama saleem

Question #146565
a program which takes as input the length of the three sides of a right angled triangle. The program should then display the cosine, sine, and tangent of the angle.
1
Expert's answer
2020-11-24T16:51:27-0500
#include <iostream>
#include <math.h>
using namespace std;

int main()
{
    float ab, bc, ac;
    cout << "Enter BC - adjacent side: \n" ;
    cin >> bc;
    cout << "Enter AC - opposite side: \n" ;
    cin >> ac;
    cout << "Enter AB - hypotenuse: \n" ;
    cin >> ab;
    
    if(pow(bc,2)+pow(ac,2)!=pow(ab,2)){
        cout << "This is not a right angled triangle!!!\n";
    }
    else{
        cout << "cosine of BAC angle is " << bc/ab << "\n";
        cout << "sine of BAC angle is " << ac/ab << "\n";
        cout << "tangent of BAC angle is " << bc/ac << "\n";
    }

    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog