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
What is typedef example?
Who is the founder of c language?
I have a varargs function which accepts a float parameter?
Is null always equal to 0(zero)?
Distinguish between actual and formal arguments.
Is c++ based on c?
What are the types of functions in c?
What is the right way to use errno?
What extern c means?
What is linear search?
Is main is user defined function?
Explain what header files do I need in order to define the standard library functions I use?
What is #line?
write a proram to reverse the string using switch case?
What is null character in c?