AIM: To write a program for evaluating the area of triangle using the formula sqrt(s(s-a)(s-b)(s-c)).
ALGORITHM:
Step1: Start the program.
Step2: Get the inputs a, r, t and s.
Step3: Calculate s = (a+b+c) / 2.
Step4: Calculate area=sqrt(s*(s-a)*(s-b)*(s-c)).
Step 5: Print the result „area‟.
Step 6: Stop the program.
PROGRAM:
#include<stdio.h>
#include<math.h>
void main()
{
int a,b,c;
float s,area;
clrscr();
printf("Enter the values of a,b,c: ");
scanf("%d%d%d",&a,&b,&c);
s=(a+b+c)/2;
area=sqrt(s*(s-a)*(s-b)*(s-c));
printf("The area of a triangle is =%f",area);
}
OUTPUT:
Enter the values of a,b,c: 10 20 30
The area of a triangle is = 0.000000
RESULT:
Thus the C program to find the area of triangle using the formula sqrt(s(s-a)(s-b)(s-c)) has
been successfully executed and verified.
No comments:
Post a Comment