PROCEDURE:-
1.Input values for three sides of triangle
2.find s value with the formulae (a+b+c)/2
3.find area with the formulae sqrt(s(s-a)(s-b)(s-c))
4.print the above result
CODE:-
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
int a,b,c;
float s, area;
printf(“enter values for 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(“\n area of triangle with sides a=%d, b=%d, c=%d is %f”, a,b,c,area);
}
Input :- enter values for three sides of triangle
a=2, b=2, c=2
Output:- area of triangle with sides a=2, b=2, c=2 is 1.732
1.Input values for three sides of triangle
2.find s value with the formulae (a+b+c)/2
3.find area with the formulae sqrt(s(s-a)(s-b)(s-c))
4.print the above result
CODE:-
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
int a,b,c;
float s, area;
printf(“enter values for 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(“\n area of triangle with sides a=%d, b=%d, c=%d is %f”, a,b,c,area);
}
Input :- enter values for three sides of triangle
a=2, b=2, c=2
Output:- area of triangle with sides a=2, b=2, c=2 is 1.732
Comments
Post a Comment