Computer Science, asked by palakpathak1915, 1 year ago


wap to input the side of two triangles calculate there are and print which one was having large area and by how much

Answers

Answered by gurukulamdivya
0

Here is your Answer:

#include <stdio.h>

int main()

{

   float base1, height1, area1, base2, height2, area2, diff;

    /* Input base and height of triangle */

   printf("Enter base and height of the first triangle: ");

   scanf("%f%f", &base1, &height1);

   printf("Enter base and height of the second triangle: ");

   scanf("%f%f", &base2, &height2);

   /* Calculate area of triangle */

   area1 = (base1 * height1) / 2;

   area2 = (base2 * height2) / 2

   /* Print the resultant area */

   printf("Area of the first triangle = %.2f sq. units", area1);

    printf("Area of the second triangle = %.2f sq. units", area2);

 if (area1>area2)

{

  printf("triangle having larger area have base %f and Height %f ", base1, height1) ;

diff=area1-area2;

printf("difference in area is %.2f sq. units", diff)

}

else

{

printf("triangle having larger area have base %f and Height %f ", base2, height2) ;

diff=area2-area1;

printf("difference in area is %.2f sq. units", diff)

}

   return 0;

}

I hope this helped you so plz rate accordingly..

Similar questions