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

Answers were Sorted based on User's Feedback



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

Answer / urja pandya

#include<stdio.h>
#include<conio.h>
float triangle (float b, float h)
{
float result;
result=(b*h)/2;
return(result);
}
void main()
{
clrscr();
float a,b,ans;
printf(“Enter the Base of Triangle: “);
scanf(“%f”,&a);
printf(“Enter the Height of Triangle: “);
scanf(“%f”,&b);
ans=triangle(a,b);
printf(“Area of Triangle is %f”,ans);
getch();
}

Is This Answer Correct ?    49 Yes 30 No

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

Answer / 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

More C Interview Questions

prog for 1st five prime numbers in 2^x - 1

0 Answers  


What is LINKED LIST? How can you access the last element in a linked list?

0 Answers   ADP,


What are the 5 types of organizational structures?

0 Answers  


study the code: #include<stdio.h> void main() { const int a=100; int *p; p=&a; (*p)++; printf("a=%dn(*p)=%dn",a,*p); } What is printed? A)100,101 B)100,100 C)101,101 D)None of the above

15 Answers   Accenture, TCS,


let's take a code struct FAQ { int a; char b; float c; double d; int a[10]; }*temp; now explain me how the memory will be allocated for the structure FAQ and what address will be in the structure pointer (temp)....................

8 Answers  






How can a string be converted to a number?

0 Answers  


What is the difference between procedural and functional programming?

0 Answers  


What happens if a header file is included twice?

0 Answers  


what will be the output of this program? void main() { int a[]={5,10,15}; int i=0,num; num=a[++i] + ++i +(++i); printf("%d",num); }

6 Answers   Microsoft,


dibakar & vekatesh..uttejana here..abt ur reply for in place reversal of linked list..wats p stands for there?

1 Answers  


what is a NULL Pointer? Whether it is same as an uninitialized pointer?

0 Answers   TISL,


What is d scanf?

0 Answers  


Categories