C Program to Calculate Area of Triangle Given Base and Height

Program


#include<stdio.h>
#include<conio.h>

int main()
{
	 float base, height, area;
	 clrscr();
	 printf("Enter base of triangle: ");
	 scanf("%f", &base);
	 printf("Enter height of triangle: ");
	 scanf("%f", &height);
	 area = 0.5*base*height;
	 printf("Area of triangle is: %0.3f", area);
	 getch();
	 return(0);
}

Output

Enter base of triangle: 6 ↲
Enter height of triangle: 7 ↲
Area of triangle is: 21.000


Note: ↲ indicates ENTER is pressed.