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

Greetings, I'm Devendra Dode, a full-stack developer, entrepreneur, and the proud owner of Tutsmake.com. My passion lies in crafting informative tutorials and offering valuable tips to assist fellow developers on their coding journey. Within my content, I cover a spectrum of technologies, including 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. Whether you're starting out or looking for advanced examples, I provide step-by-step guides and practical demonstrations to make your learning experience seamless. Let's explore the diverse realms of coding together.

Leave a Reply

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