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

Difference between C and Embedded C?

1 Answers  


#include <stdio.h> int main() { if ("X" <"x") printf("X smaller than x "); } my question is whats the mistake in this program? find it and please tell me..

3 Answers  


Program to simulate second clock

2 Answers  


Method Overloading exist in c ?

3 Answers   Wipro,


writw a program to insert an element in the begning of a doubly linked list

1 Answers  






write a program to remove occurrences the word from entered text?

1 Answers  


What is the function of ceil(X) defined in math.h do? A)It returns the value rounded down to the next lower integer B)it returns the value rounded up to the next higher integer C)the Next Higher Value D)the next lower value

3 Answers   Accenture, Wipro,


#include<stdio.h> void main() { int a=10,b=20,c=30; printf("%d",scanf("%d%d%d",&a,&b,&c)); } what is the output for this?

4 Answers   IIIT,


What is the difference between typeof(foo) and myFoo.GetType()?

2 Answers   Synergy,


What are the average number of comparisons required to sort 3 elements?

2 Answers   DRDO,


write a c program to check weather a particluar bit is set or not?

5 Answers   IBM,


program for validity of triangle from 3 side

7 Answers  






Categories