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
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 |
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 |
program to find the second largest word in a paragraph amongst all words that repeat more thn twice
What is an identifier?
What is const volatile variable in c?
consider the following structure: struct num nam{ int no; char name[25]; }; struct num nam n1[]={{12,"Fred"},{15,"Martin"},{8,"Peter"},{11,Nicholas"}}; ..... ..... printf("%d%d",n1[2],no,(*(n1 + 2),no) + 1); What does the above statement print? a.8,9 b.9,9 c.8,8 d.8,unpredictable value
Write a program for the following series: 1*3*5-2*4*6+3*5*7-4*6*8+.................up to nterms
what would be the output of the following program? main() { int k = 123; char *ptr; ptr = &k; printf("%d",*ptr); }
What is the difference between printf and scanf )?
Why do we use int main?
Software Interview Questions
write a program that finds the factorial of a number using recursion?
how to print this pyramid * * * * * * * * * * * * *
Process by which one bit pattern in to another by bit wise operation is?