Program:
#include<stdio.h>
#include<conio.h>
void main()
{
float b, h, area;
clrscr();
printf("Enter Base of Triangle : ");
scanf("%f", &b);
printf("Enter Height of Triangle :");
scanf("%f", &h);
area=((float)1/2)*b*h; /* or area = 0.5*b*h; */
printf("Area of Triangle : %.2f square units", area);
getch();
}
Output:
Enter Base of Triangle : 10
Enter Height of Triangle : 20
Area of Triangle : 100 square units
Next Topic : To enter Radius of Circle and to calculate its Area.
Previous Topic : Type casting (or) Type conversion
No comments:
Post a Comment