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

Write a c program to sort six numbers and find the largest one by using the ladder of if-else? plz do help me

2 Answers  


Write c-code for 5+55+555+5555+55555+555555+5555555. Output will be it's answer...

4 Answers   TCS,


Write a c program for sum of first n terms of the series S = 1 - (1/3) + (1/5) -(1/7) + (1/9) ......

2 Answers  


write a programe to accept any two number and check the following condition using goto state ment.if a>b,print a & find whether it is even or odd and then print.and a<b,printb.find the sum digits of that number & then print.if a==b multiply 10 with a & add 20 with b store in c and then print

0 Answers  


wats the diference btwen constant pointer and pointer to a constant.pls give examples.

9 Answers  






Bit swapping

2 Answers  


main() { int x=5; printf("%d %d %d\n",x,x<<2,x>>2); }

11 Answers   CitiGroup, College School Exams Tests, CISOC,


Two's compliment of -5

4 Answers   Adobe,


count the numbers between 100 and 300, that star with 2 and ends with 2

5 Answers   Mind Tree,


what do u mean by Direct access files? then can u explain about Direct Access Files?

0 Answers   LG Soft,


1,1,5,17,61,217,?,?.

3 Answers   Apple,


how the compiler treats any volatile variable?Explain with example.

1 Answers   Tata Elxsi,






Categories