Monday, 29 February 2016

Area of Triangle using c++

the formula for the area of a triangle is:
  or  
where b is the base, h is the height
Source code:
#include<iostream>
#include<math.h>

using namespace std;

int main()
{
    float base,height;
    float area;

    cout<<"Enter base of Triangle : ";
    cin>>base;

    cout <<"Enter height of Triangle : ";
    cin>>height;

    area = 0.5 * (base * height);
    cout<<"Area of Triangle :"<<area;
    return 0;

}

No comments:

Post a Comment