Dado el lado de un Pentágono, la tarea es encontrar el área del Pentágono.
Ejemplos:
Input : a = 5 Output: Area of Pentagon: 43.0119 Input : a = 10 Output: Area of Pentagon: 172.047745
Un pentágono regular es una forma geométrica de cinco lados cuyos lados y ángulos son iguales. Sus ángulos interiores miden 108 grados cada uno y sus ángulos exteriores miden 72 grados cada uno. La suma de los ángulos interiores de un pentágono es 540 grados.
Sea a el lado del Pentágono, luego la fórmula para encontrar el área del Pentágono dada por
Área =
C++
// C++ program to find the area of Pentagon #include<bits/stdc++.h> using namespace std; // Function to find area of pentagon float findArea(float a) { float area; // Formula to find area area = (sqrt(5 * (5 + 2 * (sqrt(5)))) * a * a) / 4; return area; } // Driver code int main() { float a = 5; // function calling cout << "Area of Pentagon: " << findArea(a); return 0; }
Java
// Java program to find the area of Pentagon import java.io.*; class GFG { // Function to find area of pentagon static float findArea(float a) { float area; // Formula to find area area = (float)(Math.sqrt(5 * (5 + 2 * (Math.sqrt(5)))) * a * a) / 4; return area; } // Driver code public static void main (String[] args) { float a = 5; System.out.println("Area of Pentagon: " + findArea(a)); } }
Python3
# Python3 program to find # the area of Pentagon # Import Math module # to use sqrt function from math import sqrt # Function to find # area of pentagon def findArea(a): # Formula to find area area = (sqrt(5 * (5 + 2 * (sqrt(5)))) * a * a) / 4 return area # Driver code a = 5 # call function findArea() # to calculate area of pentagon # and print the calculated area print("Area of Pentagon: ", findArea(a)) # This code is contributed # by ihritik
C#
// C# program to find // the area of Pentagon using System; class GFG { // Function to find // area of pentagon static float findArea(float a) { float area; // Formula to find area area = (float)(Math.Sqrt(5 * (5 + 2 * (Math.Sqrt(5)))) * a * a) / 4; return area; } // Driver code public static void Main () { float a = 5; Console.WriteLine("Area of Pentagon: "+ findArea(a)); } } // This code is contributed // by anuj_67.
PHP
<?php // PHP program to find // the area of Pentagon // Function to find // area of pentagon function findArea($a) { $area; // Formula to find area $area = (sqrt(5 * (5 + 2 * (sqrt(5)))) * $a * $a) / 4; return $area; } // Driver code $a = 5; // function calling echo "Area of Pentagon: " , findArea($a); // This code is contributed // by anuj_67. ?>
Javascript
<script> // Javascript program to find the area of Pentagon // Function to find area of pentagon function findArea(a) { let area; // Formula to find area area = (Math.sqrt(5 * (5 + 2 * (Math.sqrt(5)))) * a * a) / 4; return area; } // Driver code let a = 5; // function calling document.write("Area of Pentagon: " + findArea(a)); // This code is contributed by Mayank Tyagi </script>
Producción:
Area of Pentagon: 43.0119
Complejidad del tiempo: O(1)
Espacio Auxiliar: O(1)
Publicación traducida automáticamente
Artículo escrito por Kanishk_Verma y traducido por Barcelona Geeks. The original can be accessed here. Licence: CCBY-SA