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

1. Write the function int countchtr(char string[ ], int ch); which returns the number of times the character ch appears in the string. Example, the call countchtr(“She lives in NEWYORK”, ‘e’) would return 3.

4 Answers  


Is reference used in C?

1 Answers  


how to get the starting address of file stored in harddisk through 'C'program.

2 Answers   Siemens,


discuss the steps needed to get a program from source code to executable in a system?

1 Answers  


how to find that no is int or float?

5 Answers  






code for find determinent of amatrix

0 Answers  


What is the most efficient way to count the number of bits which are set in a value?

4 Answers  


Why we not create function inside function.

0 Answers  


Every time i run a c-code in editor, getting some runtime error and editor is disposing, even after reinstalling the software what may be the problem?

2 Answers  


how many argument we can pas in in a function

25 Answers   CTS,


why integer range between -327680to+32767

2 Answers  


Read N characters in to an array . Use functions to do all problems and pass the address of array to function. 2. Enter alphanumeric characters and form 2 array alphaets and digits.Also print the count of each array.

0 Answers  






Categories