Home >Backend Development >C++ >What is the largest square that can be inscribed in an equilateral triangle?
Here we will see the area of the largest square that can be inscribed in an equilateral triangle. The side length of the triangle is 'a' and the side length of the square is x.
The side length 'a' of the triangle is −
so x is −
#include <iostream> #include <cmath> using namespace std; float areaSquare(float a) { //a is side of triangle if (a < 0 ) //if a is negative, then this is invalid return -1; float area = a / (1 + 2/sqrt(3)); return area; } int main() { float a = 7; cout << "Area of Rectangle: " << areaSquare(a); }
Area of Rectangle: 3.24871
The above is the detailed content of What is the largest square that can be inscribed in an equilateral triangle?. For more information, please follow other related articles on the PHP Chinese website!