C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
Program to find the area of a pentagon
The Pentagon is defined as a polygon which has 5 sides that are equal. The 5 angles present in the Pentagon are also equal. A Pentagon can be divided into 5 similar triangles. The measurement of each interior angle in a regular pentagon 108 degrees.
The Formula to calculate the area of the Pentagon is,
Where s is the side of the Pentagon. Algorithm
ComplexityO(1) SolutionC Program#include Output: Area of the pentagon=162.5 PHP Program
<?php
$s=13;
$a=5;
$area_pentagon=(5/2)*$s*$a;
echo "Area of the pentagon=";
echo $area_pentagon;
?>
Output: Area of the pentagon=162.5 Java Program
public class pentagon{
public static void main(String args[])
{
int s=13;
int a=5;
float area_pentagon=(float)(5.0/2.0)*s*a;
System.out.println("Area of the pentagon="+area_pentagon);
}
}
Output: Area of the pentagon=162.5 C# Program
using System;
public class Program
{
public static void Main()
{
int s=13;
int a=5;
double area_pentagon=(double)(5.0/2.0)*s*a;
Console.WriteLine("Area of the pentagon="+area_pentagon);
}
}
Output: Area of the pentagon=162.5 Python Program
s=13
a=5
area_pentagon=(5.0/2.0)*s*a
print("Area of the pentagon="+str(area_pentagon))
Output: Area of the pentagon=162.5
Next Topic#
|