Write a function to find the area of a triangle whose
length of three sides is given

Answer Posted / gajendra patil

#include <stdio.h>
#include <math.h>
float tarea(int a,int b,int c){
int cond1=0,cond2=0;
float s,area;
if((a > 0.0) && (b > 0.0) && (c > 0.0)){
cond1 = 1;
}
if((a+b > c) && (a+c > b) && (b+c > a)){
cond2 = 1;
}
if(cond1 && cond2){
s=(a+b+c)/2.0;
area= (sqrt(s*(s-a)*(s-b)*(s-c)));
printf("=================================\n");
printf("AREA OF TRIANGLE IS [ %f ]\n",area);
printf("=================================\n");

}else
printf("\nERROR: This is not a triangle!\n");
};

int main(){
int a,b,c;
float area;
printf("\nArea of Triangle");
printf("\n-------------------------\n");
printf("Enter three sides: \n");
printf("\nEnter size for a: ");
scanf("%d",&a);
printf("\nEnter size for b: ");
scanf("%d",&b);
printf("\nEnter size for c: ");
scanf("%d",&c);
tarea(a,b,c);

return 0;
}

Is This Answer Correct ?    15 Yes 9 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is typedef example?

616


Who is the founder of c language?

685


I have a varargs function which accepts a float parameter?

579


Is null always equal to 0(zero)?

585


Distinguish between actual and formal arguments.

589






Is c++ based on c?

652


What are the types of functions in c?

572


What is the right way to use errno?

621


What extern c means?

540


What is linear search?

678


Is main is user defined function?

597


Explain what header files do I need in order to define the standard library functions I use?

649


What is #line?

611


write a proram to reverse the string using switch case?

2469


What is null character in c?

691