Largest square that can be inscribed in a semicircle | C ++ Program to find the biggest square which can be inscribed within the semicircle ; Function to find the area of the square ; the radius cannot be negative ; area of the square ; Driver code
#include <bits/stdc++.h> NEW_LINE using namespace std ; float squarearea ( float r ) { if ( r < 0 ) return -1 ; float a = 4 * ( pow ( r , 2 ) / 5 ) ; return a ; } int main ( ) { float r = 5 ; cout << squarearea ( r ) << endl ; return 0 ; }