Geometry: Area of a Hexagon

less than 1 minute read

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

Question

<— Return Home

44.cpp

#include <iostream>
#include <cmath>
using namespace std;

int main(){
   double area;
   double s;

   std::cout << "Enter the side: \n";
   std::cin >> s;

   area = (6 * pow(s, 2)) / (4 * tan(M_PI / 6));
   
   std::cout << "The area of the hexagon is " << area << "\n";
}

<— Return Home