C Program Area Of Equaliteral Triangle | C Programs

There you go another program to find C Program area of Equilateral Triangle. You can check out our programs below, we do written the codes in three different ways. Also, do leave a comment here at the end of the post.

Using Standard

1)For calculating the area of equaliteral  triangle we need only side of the triangle.

2)The value of side will store into the variable “a”,and “a” value will be substituted into the formula ,then we get the area value.

output:

Using Functions

1)We are using the function area(float a) to calculate area of equaliteral triangle,here the return type is float.

2)area(a) is calling the function which is having float datatype argument,here area(float a) having float datatype argument “a”

3)area(float a) calculate  the area of equilateral triangle and return the area value,that value will assigned to  the variable “Ar”.

output:

Using Pointers

1)We are calling the function as area(&a,&Ar),here we are passing the references/addresses of variables a,Ar.

2)The function area(float *a,float *Ar) will calculate the area of equaliteral triangle,which is having pointers as arguments.

3)The calculated value will store into the pointer variable “Ar”

output:

Using Macros

1)Line 3 represents area(a) is symbolic name to the expression (sqrt(3)/4)*a*a.

2)area(a)replaced with that expression given at #define.

output:

Add a Comment

Your email address will not be published. Required fields are marked *