The area of the triangle is A=hb/2. This is the mathematics formula to find out the area of the triangle. We can convert it to the C programming language. First of all, understand the formula.
Area of the triangle A = hb/2.
A represents the area of the triangle.
h represents the height of the triangle.
b denotes the base of the triangle
Now, convert it to C programming language.
Create a program to find out the area of the triangle in C language -
We can use the math header files in the C program. To get the exact area of the triangle in the C program, you need to convert into C programming.
There are three variables like a,b, h.
a = Area of the triangle in the C program.
b= Base of the triangle in the C program.
h = Height of the triangle in the C program.
Let's create an example in C language -
#include <stdio.h>
#include<math.h>
int main()
{
float a;
float b=4.0;
float h=4.0;
a=h*b/2;
printf("Area of triangle= %.2f\n", a);
return 0;
}
Compile and execute the C program. You will get the area of the triangle as output.
Area of triangle= 8.00