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 are actual arguments?
Why c is a mother language?
Is a house a mass structure?
Explain the priority queues?
i have a written test for microland please give me test pattern
Is main an identifier in c?
what do you mean by inline function in C?
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.
Why are algorithms important in c program?
What are multibyte characters?
What is the difference between formatted&unformatted i/o functions?
Explain how does flowchart help in writing a program?
Write a program to print "hello world" without using a semicolon?
write a program to generate address labels using structures?
What are 'near' and 'far' pointers?