please write aprogramme to find area of triangle
please write aprogramme to find area of triangle
if base and height were given, 1/2(base*height) is the formula to be used -
main()
{
/* Declare variables base and height */
long base;
long height;
/* display and ask for the value of base*/
printf("Type a length of the base: ");
scanf( "%ld", &base);
/* display and prompt for value of height */
printf("Type the height of the triangle: ");
scanf( "%ld", &height);
/* Find half of the base */
float halfbase = .5 * base;
printf( "\nHalf of base is: %f\n\n", halfbase);
/* Find result of the base */
float result = halfbase * height;
printf("The area for the triangle with the base of %ld and the height %ld is %f\n", base, height, result);
}
Another method to find area of the triangle if lengths of the sides are given..
Heron's Formula for Computing Triangle Area Using External Functions
With the amount of detailed steps in the above link, I don't think it is difficult for anyone to write program for it. But if you have any problems, let me know.
Thanks,
Krishna
#include
#include
#include
voidmain()
{
clrscr();
int a,b,c,s,area;
printf("enter the values of the sides of the triangle\n");
scanf("%d%d%d",&a,&b,&c);
s=(a+b+c)/2;
area=squrt(s*(s-a)*(s-b)*(s-c));
printf("the area of the triangle is %d",area);
getch();
}
There are currently 1 users browsing this thread. (0 members and 1 guests)