This is C program that asks user to find the area of a triangle using math’s function. Here user declares some variables that use to store the value of it. User asks to enter the value of triangle three sides of triangle. Here after value user using the method to find the area of triangle. And then print the result on the screen.
Problem statement:
This is C program that asks user to find out the area of triangle.
- Declare the variable.
- Using method of Triangle area function.
- Display result on the screen.
Method of Find area of Triangle:
” Area=sqrt(s*(s-a)*(s-b)*(s-c)); “
Here is C source code for finding the area of triangle. The output of this program shown below.
# include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
int a,b,c;
float area, s;
clrscr();
printf("Enter the Three Sides of Triangle : ");
scanf("%d %d %d" ,&a, &b, &c);
s=(a+b+c)/2.0;
area=sqrt(s*(s-a)*(s-b)*(s-c));
printf("Area of the Triangle= %f ", area);
getch();
}