Program for finding the area of triangle when three sides are given

0
36
#include<stdio.h>
#include<conio.h>
void main()
{
  float a,b,c,s,area;
  clrscr();
  printf("Enter three sides a b c\n");
  scanf("%f%f%f",&a,&b,&c);
  if((a<=0)||(b<=0)||(c<=0))   /* a side of a triangle can not be 
                                     0 or -ve number */
    printf("\n given sides can not form a triangle \n");
  else
  if(((a+b)<=c)||((a+c)<=b)||((b+c)<=a))  /* to form a triangle sum of any two
                                             sides must greater than third side */
    printf("\n given sides can not form a triangle \n");
  else    /* there is possibility of triangle formation */
       {
        s=(a+b+c)/2;
        area=squt(s*(s-a)*(s-b)*(s-c));
        printf("\n area = %.4f \n", area);
       }
getch();
}
   Output 1:
   Enter three sides a b c
   2 3 4
   area = 2.9047
   Output 2:
   Enter three sides a b c
   given sides can not form a triangle

Note: This program takes time as input in terms of seconds, minutes and hours and checks for its validity and increases the input time by one second.

 

 

Program for finding the area of triangle when three sides are given Program for finding the area of triangle when three sides are given in cc Program for finding the area of triangle when three sides are given Program for finding the area of triangle find the area of triangle

 

LEAVE A REPLY

Please enter your comment!
Please enter your name here