×

Program to calculate the area of the circumcircle of an equilateral triangle

You have given one value which represents the side of the equilateral triangle. You have to find out the area of the circumcircle. Let’s take an example -

Program To Calculate The Area Of The Circumcircle Of An Equilateral Triangle

For the above diagram, we have an equilateral triangle named ABC. We have to find out the area of its circumcircle.

Input-

6

Output-

37.69

Explanation- 6 is the value of the side of an equilateral triangle. By calculating the area of the circumcircle, we get the answer 37.69.

Note: -

What is the equilateral triangle?

Triangle has three sides, and an equilateral triangle is a triangle whose three sides are equal. It means, according to the above diagram, the sides AB, BC, and CA are of the same length.

AB = BC = CA

What is the circumcircle?

A circumcircle is a special type of circle. For various types of polygons, we can get circumcircles. It is a circle which goes through every vertex of the polygon. We can calculate different properties of the circle by using different properties of the polygon. A circumcircle of an equilateral triangle goes through three vertices of the triangle.

Algorithm:-

Step 1: Start

Step 2: The value of the sides of a triangle is taken from the user

Step 3: A function is called to calculate the area.

Step 4: In this function, we take the input value, which represents the side of the triangle.

Step 5: The floating point variable is declared in function to store the area

Step 6: The area is calculated.

Step 7: The value of the calculated area is returned.

Step 8: The returned value will be printed.

Step 9: Stop.

Explanation of Algorithm: - Let's try to understand the algorithm by the above diagram. We have an equilateral triangle ABC whose each side is the same in length ( AB = BC = CA ). If we consider the point 'O' as the centre of the circle that goes through each vertex of the triangle, then the value of OA is the radius of the circle. From geometry, we know that the intersection point of all medians of a triangle is the centre of the circumcircle of the equilateral triangle. In this way, we can get the value of the radius of the circle based on the side of the triangle. So, radius = a/ ( root of 3 ).

The formula of area of circle is

Here r = a/

So, area =

Code: -

// Program in CPP to calculate the area of circum.
Circle of an equilateral triangle
#include <iostream>
#include <math.h>
using namespace std;
// function to calculate the area of circumcircle
// of equilateral triangle
float area_circumscribed(float a)
{
	return (a * a * (3.14 / 3));
}
// Driver code
int main()
{
	float a, Area;
	cin >> a;
	// function calling
	Area = area_circumscribed(a);
	// displaying the area
	cout << " The value of triangle side = " << a;
cout << “Area of CircumCircle = ”  << Area;
	return 0;
}

Program in C

// Program in c to calculate the area of circum
circle of an equilateral triangle
#include <stdio.h>
#define PI 3.14159265
// function to find area of
// circumscribed circle
float area_circumscribed(float a)
{
	return (a * a * (PI / 3));
}
// Driver code
int main()
{
	float a = 6;
	printf("Area of circumscribed circle is :%f",
			area_circumscribed(a));
	return 0;
}


Program in Java

// Program in java to calculate the area of the circum
circle of an equilateral triangle
import java. lang.*;
class jtp {	
	static double PI = 3.14159265;
	// function to find the area of
	// circumscribed circle
	public static double area_circumscribed(double a)
	{
		return (a * a * (PI / 3));
	}
	// Driver code
	public static void main(String[] args)
	{
		double a = 6.0;
		System.out.println("Area of circumscribed circle is :"
		+ area_circumscribed(a));
	}
}

Program in Python

// Program in python to calculate the area of the circum
circle of an equilateral triangle
PI = 3.14159265	
# Function to find the area of
# circumscribed circle
def area_circumscribed(a):
	return (a * a * (PI / 3))	
# Driver code
a = 6.0
print("Area of circumscribed circle is :%f"
       %area_circumscribed(a))

Output:

1.	 The value of triangle side = 6
Area of CircumCircle = 37.69
2.	The value of triangle side = 9
Area of CircumCircle = 84.82
3.	The value of triangle side = 3
Area of CircumCircle = 9.42

Complexity Analysis: -

Time complexity- Here, we need no recursion or looping so we can find the solution within constant time. Time complexity will be O (1).

Space complexity- In this solution, we use constant memory. So, space complexity will be O(1).


Related Topics

What are Forest Trees in Data Structure

Data structure A data model manages and optimizes computer resources, and a database stores and manages data. It's one of many uses for data structures to hold data. Data structures come...

5 minutes read.

Tree vs Graph: Data Structure

Difference Between Tree and Graph What is Tree? A tree is a non-linear data structure and finite collection of elements called node. A tree, in which the data items are arranged in...

3 minutes read.

How to Start Learning DSA

All programmer experiences a point along the way where they wish they could approach a problem in a more effective manner. They finally learn about the terminology DSA while trying...

10 minutes read.

Function to Insert a Node in a Binary Search Tree

Implementation // writing C++ code that will help us in implementing the insertion operation in a binary search tree. #include <bits/stdc++.h> using namespace std; // creating a new binary search tree node struct __nod { int...

8 minutes read.

What is a Spanning Tree in Data Structure

Data structures Data management is called database management. This allows the computer to sort or organize the data for efficient retrieval. A data model is a system used to store, manage,...

5 minutes read.

Sort the linked list of 0s, 1s and 2s

Sort the linked list of 0s, 1s and 2s In this, we are given a linked list of 0s, 1s, and 2s, and we need to sort it. Examples: Input: 1  ->  1 ...

2 minutes read.

Priority Queue in Data Structure

Priority Queue A priority queue is a special kind of queue, in priority queue we give some priority to an element and according to this priority an element can be served...

3 minutes read.

FLEX (Fast Lexical Analyzer Generator)

FLEX stands for Fast Lexical Analyzer Generator. Around 1987, Vern Paxson created Flex in C with a great deal of input and inspiration from Van Jacobson. Van Jacobson's approach is...

3 minutes read.

What Is Dfs Algorithm in Data Structures

DFS stands for Depth First Search. Generally, it is a repetitive or decidable type of algorithm which is basically used in identifying all the vertices or nodes of a graph...

5 minutes read.

Recursion in Fibonacci

Fibonacci heap is considered to be a particular execution of the heap data structure that ultimately helps in making use of not just any number but the Fibonacci numbers. It...

3 minutes read.

Equal Sum

Find an element in array such that the sum of left array is equal to the sum of right array You have been given an array of numbers. You have to...

4 minutes read.

LCA of binary tree

Implementation //Writing a program to find the lowest common factor in a given binary search tree. #include <iostream> #include <vector> using namespace std; // the very first step is to create a binary tree. struct __nod { int...

8 minutes read.

Stack Data Structure

The stack is a non-primitive and linear data structure. It works on the principle of LIFO (Last In First Out). That is, the element that is added to the end...

3 minutes read.

Operations of B++ tree

Insertion When we discuss the insertion operation in the B++ tree, this operation helps us in pushing a new element in the tree at any given place. In this case, the...

17 minutes read.

What is the difference between Tree and Graph

We usually use a diverse range of data structure to store our data and information. To store them in a more sequential manner and to access them easily, we use...

4 minutes read.

Threaded Binary Trees

Introduction Threaded Binary Trees (TBTs) are an enhancement of normal binary trees intended for in-order traversal only. This means that this data structure is developed with the objective of making the...

12 minutes read.

Detect and Remove Loop in a Linked List

Create a function called detectAndRemovetheLoop() that verifies whether a given Linked List has a loop, eliminates the loop if it does, and returns true if it does. It returns false...

6 minutes read.

Delete a Node without head pointer from the linked list

Delete a Node without head pointer from the linked list This article will explain how to delete a node without a head pointer from the linked list. We have given a...

2 minutes read.

Hashing

Hashing: Hashing is a process in which a large amount of data is mapped to a small table with the help of hashing function. It is a searching technique. Hash table We...

4 minutes read.

What Should We Learn First? Trees or Graphs in Data Structures

A data structure is a database used to store and manage data and optimize and manage computing resources. A data structure is a form used intelligently and quickly to store,...

6 minutes read.