A function returning the area and perimeter of a triangle.

#include <stdio.h>
#include <math.h>

void tAreaPeri(float, float, float, float *, float *);

int main(void)
{
float s1, s2, s3, area, peri;

printf("\nEnter the three sides : ");
scanf("%f%f%f", &s1, &s2, &s3);

tAreaPeri(s1, s2, s3, &area, &peri);

printf("\nArea is %f\nPerimeter is %f", area, peri);

return 0;
}

void tAreaPeri(float s1, float s2, float s3, float *ap, float *pp)
{
float semi_peri;

*pp = s1 + s2 + s3;
semi_peri = 0.5 * (*pp);
*ap = sqrt(semi_peri * (semi_peri - s1) * (semi_peri - s2) * (semi_peri - s3));
}

No comments:

Post a Comment

kiss on google ads if you are anonymous because your ip is trackable.thank you.

......from.admin