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 are actual arguments?

637


Why c is a mother language?

544


Is a house a mass structure?

632


Explain the priority queues?

611


i have a written test for microland please give me test pattern

2167






Is main an identifier in c?

587


what do you mean by inline function in C?

605


 write a program that will open the file, count the number of occurences of each word in the the complete works of shakespeare.  You will then tabulate this information in another file.

1719


Why are algorithms important in c program?

610


What are multibyte characters?

637


What is the difference between formatted&unformatted i/o functions?

604


Explain how does flowchart help in writing a program?

615


Write a program to print "hello world" without using a semicolon?

585


write a program to generate address labels using structures?

3996


What are 'near' and 'far' pointers?

605