Wednesday, 12 December 2018

Practice Functions #4 [Calculate Area of a Triangle]

===========================================================================
                                CODING



#include<iostream.h>
#include<conio.h>
#include<math.h>

float Area(float,float,float);

void main()
{
    clrscr();
    float a,b,c;
    cout<<"      Area of a Triangle";
    cout<<"\n      ------------------";
    cout<<"\n\n    ¯Enter 1st Side: ";
    cin>>a;
    cout<<"\n\n    ¯Enter 2nd Side: ";
    cin>>b;
    cout<<"\n\n    ¯Enter 3rd Side: ";
    cin>>c;
    cout<<"\n\n  => Area: "<<Area(a,b,c)<<" sq units";
    getch();
}

float Area(float a,float b,float c)
{
    float s,Ar;
    s=(a+b+c)/2;
    Ar=sqrt(s*(s-a)*(s-b)*(s-c));
    return Ar;
}




===========================================================================

                                OUTPUT


No comments:

Post a Comment