Geometry: Area of a Pentagon

less than 1 minute read

The code has been modified slightly and now uploaded to the site.

Question

Question

<— Return Home

41.cpp

// USING GITPOD
#include <iostream>
#include <cmath>
using namespace std;

int main(){
    double radius;
    double area;
    double s;

    std::cout << "Enter radius of pentagon: \n";
    std::cin >> radius;

    s = 2 * radius * sin(M_PI / 5);

    area = (5 * pow(s, 2)) / (4 * tan(M_PI / 5));

    std::cout << "The area of the pentagon is: " << area << "\n";
}

<— Return Home