plz help me to write a code in c++

find out the base and height of the triangle and find out perimeter and area of triangle in c++

“find out base and height” or “accept base and height from user and find the area and perimeter?”

accept base and height from user and find the area and perimeter?

My solution works provided the given triangle is right angled triangle, I think one more parameter is needed to solve it for a general triangle, btw my sol:-

    #include <iostream>
    #include <cmath>

    #define sq(x) x*x

    using namespace std;

    int main()
    double height, base;  
    cout<<"Area= "<<(base*height)/2<<"\n";  
    double hypotenuse;  
    hypotenuse = sqrt(sq(base)+sq(height)); 
    cout<<"Perimeter="<< base+height+hypotenuse<<"\n";  
    return 0;  

@v_akshay it is not necessarily a right angled triangle!!!

even other triangles have base and height!!!

@kunal361, well, everyone knows that, I think you haven’t read my statement as I said to solve a general triangle i.e (to know the measure of all the 3 angles and 3 sides ) we need atleast 3 parameters.

there are 5 possible cases for solving a triangle :

  1. SSS :- sides are given and we need to find angles, we use cosine rule
    B=arccos(a^2+c^2−b^2)/2 ac

  2. SAS :- 2 sides and the included angle is given

  3. ASA

  4. SSA

  5. AAA :- we need to find the ratios of sides which can be done using

    sine rule sinA/a=sinB/b=sinC/c

In the question asked we are only given 2 parameters and we need to find all the sides in order to find the perimeter, You an easily tell that you are a variable short. Thats why I have assumed that the triangle is a right angled triangle!