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 the use of putchar function?
What is wrong in this statement?
How do we print only part of a string in c?
What is the -> in c?
Linked lists -- can you tell me how to check whether a linked list is circular?
An expression to whose value an operater is applied a) operand b) variable c) constant d) all of the above
What is console in c language?
in case any function return float value we must declare a) the function must be declared as 'float' in main() as well b) the function automatically returned float values c) function before declared 'float' keyword d) all the above
How can I prevent another program from modifying part of a file that I am modifying?
Do you know the use of 'auto' keyword?
What is maximum size of array in c?
Why use int main instead of void main?
What is the purpose of & in scanf?
What are derived data types in c?
What does struct node * mean?