Thursday, 16 November 2017

C Program to Calculate the Area of a Triangle


Code:

#include   stdio.h
#include   math.h

void main()
{
    int s, a, b, c, area;

    printf("Enter the values of a, b and c \n");
    scanf("%d %d %d", &a, &b, &c);
    /* compute s */
    s = (a + b + c) / 2;
    area = sqrt(s * (s - a) * (s - b) * (s - c));
    printf("Area of a triangle = %d \n", area);
}


Output:

Enter the values of a, b and c
12 10 8
Area of a triangle = 39


More C Programs:












100+ Best Home Decoration Ideas For Christmas Day 2019 To Make Home Beautiful

Best gifts for Christmas Day | Greeting cards for Christmas Day | Gift your children a new gift on Christmas day This Christmas d...