TheDeveloperBlog.com

Home | Contact Us

C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML

program to find the area of a Pentagon

program to find the area of a Pentagon on fibonacci, factorial, prime, armstrong, swap, reverse, search, sort, stack, queue, array, linkedlist, tree, graph etc.

<< Back to PROGRAM

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.

Program to find the area of a pentagon

The Formula to calculate the area of the Pentagon is,

Program to find the area of a pentagon

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)


Solution

C Program

#include 
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

Next Topic#




Related Links:


Related Links

Adjectives Ado Ai Android Angular Antonyms Apache Articles Asp Autocad Automata Aws Azure Basic Binary Bitcoin Blockchain C Cassandra Change Coa Computer Control Cpp Create Creating C-Sharp Cyber Daa Data Dbms Deletion Devops Difference Discrete Es6 Ethical Examples Features Firebase Flutter Fs Git Go Hbase History Hive Hiveql How Html Idioms Insertion Installing Ios Java Joomla Js Kafka Kali Laravel Logical Machine Matlab Matrix Mongodb Mysql One Opencv Oracle Ordering Os Pandas Php Pig Pl Postgresql Powershell Prepositions Program Python React Ruby Scala Selecting Selenium Sentence Seo Sharepoint Software Spellings Spotting Spring Sql Sqlite Sqoop Svn Swift Synonyms Talend Testng Types Uml Unity Vbnet Verbal Webdriver What Wpf