C++ program of finding 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:


Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s