Q:

Program to find the area of a pentagon

belongs to collection: Basic Programs

0

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.
a is the apothem length.

Algorithm

  1. Create variables 's' and 'a' and assign its value as 10 and 6.
  2. Create variable area_pentagon equals to (5/2)X(s)X(a) as per the formula of calculating the area of the Pentagon.

Complexity

O(1)

Input:

s = 13  

a = 5;  

Output:

Area of Pentagon = (5.0/2.0) * s * a
                 = (5.0/2.0) * 13 * 5
                 = 162.5

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

C Program

#include <stdio.h>  
int main()  
{  
   int s=13;  
   int a=5;  
   float area_pentagon=(5.0/2.0)*s*a;  
   printf("Area of the pentagon=%0.1f",area_pentagon);  
}  

 

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

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Program to find the area of the parallelogram... >>
<< Program to calculate the volume of the sphere...