Friday, 29 April 2016

C++ Program to find the area of triangle using Hero's Formula

In this program we will find area of triangle in C++ using Hero's Formula

//Code Starts



#include<iostream>

#include<math.h>

using namespace std;

int main()

{

    float first,second,third;

    float s,area;

    cout<<"Enter size of each sides of triangle"<<endl;

    cout<<"Enter size for First Side =";

    cin>>first;

    cout<<"Enter size for Second Side =";

    cin>>second;

    cout<<"Enter size for Third Side =";

    cin>>third;

    s = (first+second+third)/2;

    area = sqrt(s*(s-first)*(s-second)*(s-third));

    cout<<"Area of Triangle= "<<area<<endl;

    return 0;

}
//Code Ends

OUTPUT:






Share:

0 comments:

Post a Comment