C Program to find Area of an Equilateral Triangle

C Program to find Area of an Equilateral Triangle

C program to find area of equilateral Triangle; Through this tutorial, we will learn how to find or calculate area of equilateral Triangle using standard formula, function and pointer in c programs.

Programs and Algorithm to Find Area of Equilateral Triangle

Use the below given algorithm and programs to find or calculate area of equilateral Triangle using standard formula, function and pointer in c:

  • Algorithm to Find Area of a Equilateral Triangle
  • C Program to Find Area of a Equilateral Triangle using sqrt
  • C Program to Find Area of a Equilateral Triangle using Function
  • C Program to Find Area of a Equilateral Triangle using Pointer

Algorithm to Find Area of a Equilateral Triangle

Use the following algorithm to write a program to find the area of a equilateral Triangle; as follows:

  1. Take input side of triangle. Store it in variable.
  2. Calculate area of an Equilateral triangle using (sqrt 3)/4 * a^2
  3. Finally, print the value of Area of an Equilateral triangle.

C Program to Find Area of a Equilateral Triangle using sqrt

#include<math.h>
int main()
{
	float area,a;
	printf("enter side of the triangle: ");
	scanf("%f",&a);
 
	area=(sqrt(3)/4)*a*a;
	printf("AOET:%f\n",area);
	return 0;
}

The output of the above c program; as follows:

enter side of the triangle: 5
AOET:10.825317

C Program to Find Area of a Equilateral Triangle using Function

#include<stdio.h>
#include<math.h>
float area(float a)
{
	float Ar=(sqrt(3)/4)*a*a;
        return Ar;
}
 
int main()
{
	float Ar,a;
	printf("enter side of the triangle: ");
	scanf("%f",&a);
 
	
	Ar=area(a);
	printf("AOET: %f\n",Ar);
	return 0;
}

The output of the above c program; as follows:

enter side of the triangle: 7
AOET: 21.217623

C Program to Find Area of a Equilateral Triangle using Pointer

#include<stdio.h>
#include<math.h>
float area(float *a,float *Ar)
{
  
	*Ar=(sqrt(3)/4)* (*a) * (*a);   
    
}
 
int main()
{
	float a,Ar;
	printf("enter side: ");
	scanf("%f",&a);
	area(&a,&Ar);
	printf("AOET: %f\n",Ar);
	return 0;
}

The output of the above c program; as follows:

enter side: 6
AOET: 15.588457

Recommended C Programs

AuthorAdmin

My name is Devendra Dode. I am a full-stack developer, entrepreneur, and owner of Tutsmake.com. I like writing tutorials and tips that can help other developers. I share tutorials of PHP, Python, Javascript, JQuery, Laravel, Livewire, Codeigniter, Node JS, Express JS, Vue JS, Angular JS, React Js, MySQL, MongoDB, REST APIs, Windows, Xampp, Linux, Ubuntu, Amazon AWS, Composer, SEO, WordPress, SSL and Bootstrap from a starting stage. As well as demo example.

Leave a Reply

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