C program to find area of a triangle.

Q42. Write a C program to find area of a triangle.

Ans.

#include<stdio.h>  //for standard input and output

#include<conio.h>  //for clrscr()

 

//Main() function

void main()

{

float height,base,area;

clrscr();  //for clear screen

printf(“\n Enter the height and base of the triangle: “);

scanf(“%f %f”,&height,&base);

area=(height*base)/0.5;

printf(“\n The area of triangle is: %f”,area);

getch();  //To hold the output screen

}

//End of main()

Output:

 

Enter the height and base of the triangle: 5  9.6

The area of triangle is: 96.000000