+1 vote

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.

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

0 votes

The mathematics is the base of every programming to execute the code in right way.You are mentioned to find out the area of the triangle.

Let's understand with the steps -

1. Area of the triangle - A=bh/2.

2. Think about the variable in the formula . You must create the variables in the C programming language. There are three variables in that mathematics formula.

3. Declare three variables in the C program. We assign the data type with the variable in C language

float a;

float b;

float h;

4. Define the variable value.

b=4.5;

h=3.6;

6. Convert area formula in the C language.

a=h*h/2;

7. Print the value of a.

This is the way to find out the area of the triangle in the C programming language.