Q6 If lengths of three sides of a triangle are input through the keyboard, write a program to find the area of the triangle.

Area of Triangle

Program: 64

If lengths of three sides of a triangle are input through the keyboard, write a program to find the area of the triangle.

 

#include<stdio.h>
#include<conio.h>
#include<math.h>
int main()
{
    int a, b, c;     //Triangle side's lengths
    float s=0, area=0;
    printf("Enter Length of AB: ");
    scanf("%d", &a);
    printf("Enter Length of BC: ");
    scanf("%d", &b);
    printf("Enter Length of CA: ");
    scanf("%d", &c);

    s = (a+b+c)/2;

    area = sqrt(s*(s-a)*(s-b)*(s-c));
    printf("Area of Triangle is: %f", area);
    return 0;
}

Output:

 Enter Length of AB: 3
Enter Length of BC: 4
Enter Length of CA: 5
Area of Triangle is: 6.000000
Lokesh Kumar: Being EASTER SCIENCE's founder, Lokesh Kumar wants to share his knowledge and ideas. His motive is "We assist you to choose the best", He believes in different thinking.
Related Post
Leave a Comment

This website uses cookies.