# Find the area of the shaded region formed by the intersection of four semicircles in a square

Given the length of the side of a square **a**, the task is to find the area of the shaded region formed by the intersection of four semicircles in a square as shown in the image below:

**Examples:**

Input:a = 10

Output:57

Input:a = 19

Output:205.77

**Approach:** Area of the shaded region will be:

Area(semicircle1) + Area(semicircle2) + Area(semicircle3) + Area(semicircle4) – Area(square).Since all semicircles are of same radius, therefore, area of all semicircles will be equal. So, the above formula can be written as:

4*(Area of Semicircle) – Area(Square)

The area of a semicircle is **(3.14 * r ^{2}) / 2** where

**r**is the radius of the semicircle which is equal to

**a / 2**.

Hence, **Area of the shaded region = 4 * (3.14 * (a * a) / 8 ) – a * a**

Below is the implementation of the above approach:

## C++

`// C++ implementation of the approach ` `#include <bits/stdc++.h> ` `using` `namespace` `std; ` ` ` `// Function to return the area ` `// of the shaded region ` `float` `findAreaShaded(` `float` `a) ` `{ ` ` ` ` ` `// Area of the square ` ` ` `float` `sqArea = a * a; ` ` ` ` ` `// Area of the semicircle ` ` ` `float` `semiCircleArea = (3.14 * (a * a) / 8); ` ` ` ` ` `// There are 4 semicircles ` ` ` `// shadedArea = Area of 4 semicircles - Area of square ` ` ` `float` `ShadedArea = 4 * semiCircleArea - sqArea; ` ` ` ` ` `return` `ShadedArea; ` `} ` ` ` `// Driver code ` `int` `main() ` `{ ` ` ` `float` `a = 10; ` ` ` `cout << findAreaShaded(a); ` ` ` ` ` `return` `0; ` `} ` |

*chevron_right*

*filter_none*

## Java

`// Java implementation of the approach ` `class` `GFG { ` ` ` ` ` `// Function to return the area ` ` ` `// of the shaded region ` ` ` `static` `float` `findAreaShaded(` `float` `a) ` ` ` `{ ` ` ` ` ` `// Area of the square ` ` ` `float` `sqArea = a * a; ` ` ` ` ` `// Area of the semicircle ` ` ` `float` `semiCircleArea = (` `float` `)(` `3.14` `* (a * a) / ` `8` `); ` ` ` ` ` `// There are 4 semicircles ` ` ` `// shadedArea = Area of 4 semicircles - Area of square ` ` ` `float` `ShadedArea = ` `4` `* semiCircleArea - sqArea; ` ` ` ` ` `return` `ShadedArea; ` ` ` `} ` ` ` ` ` `// Driver code ` ` ` `public` `static` `void` `main(String[] args) ` ` ` `{ ` ` ` `float` `a = ` `10` `; ` ` ` `System.out.println(findAreaShaded(a)); ` ` ` `} ` `} ` |

*chevron_right*

*filter_none*

## Python3

`# Python3 implementation of the approach ` ` ` `# Function to return the area ` `# of the shaded region ` `def` `findAreaShaded(a): ` ` ` ` ` `# Area of the square ` ` ` `sqArea ` `=` `a ` `*` `a; ` ` ` ` ` `# Area of the semicircle ` ` ` `semiCircleArea ` `=` `(` `3.14` `*` `(a ` `*` `a ) ` `/` `8` `) ` ` ` ` ` `# There are 4 semicircles ` ` ` `# shadedArea = Area of 4 semicircles - Area of square ` ` ` `ShadedArea ` `=` `4` `*` `semiCircleArea ` `-` `sqArea ; ` ` ` ` ` `return` `ShadedArea; ` ` ` `# Driver code ` `if` `__name__ ` `=` `=` `'__main__'` `: ` ` ` `a ` `=` `10` ` ` `print` `(findAreaShaded(a)) ` |

*chevron_right*

*filter_none*

## C#

`// C# implementation of the approach ` `using` `System; ` ` ` `class` `GFG ` `{ ` ` ` ` ` `// Function to return the area ` ` ` `// of the shaded region ` ` ` `static` `float` `findAreaShaded(` `float` `a) ` ` ` `{ ` ` ` ` ` `// Area of the square ` ` ` `float` `sqArea = a * a; ` ` ` ` ` `// Area of the semicircle ` ` ` `float` `semiCircleArea = (` `float` `)(3.14 * (a * a) / 8); ` ` ` ` ` `// There are 4 semicircles ` ` ` `// shadedArea = Area of 4 semicircles - Area of square ` ` ` `float` `ShadedArea = 4 * semiCircleArea - sqArea; ` ` ` ` ` `return` `ShadedArea; ` ` ` `} ` ` ` ` ` `// Driver code ` ` ` `public` `static` `void` `Main() ` ` ` `{ ` ` ` `float` `a = 10; ` ` ` `Console.WriteLine(findAreaShaded(a)); ` ` ` `} ` `} ` ` ` `// This code is contributed by mohit kumar 29 ` |

*chevron_right*

*filter_none*

## PHP

`<?php ` `// PHP implementation of the approach ` ` ` `// Function to return the area ` `// of the shaded region ` `function` `findAreaShaded(` `$a` `) ` `{ ` ` ` ` ` `// Area of the square ` ` ` `$sqArea` `= ` `$a` `* ` `$a` `; ` ` ` ` ` `// Area of the semicircle ` ` ` `$semiCircleArea` `= (3.14 * (` `$a` `* ` `$a` `) / 8); ` ` ` ` ` `// There are 4 semicircles ` ` ` `// shadedArea = Area of 4 semicircles - ` ` ` `// Area of square ` ` ` `$ShadedArea` `= 4 * ` `$semiCircleArea` `- ` `$sqArea` `; ` ` ` ` ` `return` `$ShadedArea` `; ` `} ` ` ` `// Driver code ` `$a` `= 10; ` `echo` `findAreaShaded(` `$a` `); ` ` ` `// This code is contributed by Ryuga ` `?> ` |

*chevron_right*

*filter_none*

**Output:**

57

## Recommended Posts:

- Program to find the area of a Square
- Program to find the surface area of the square pyramid
- Program to find the number of region in Planar Graph
- Smallest square formed with given rectangles
- Area of triangle formed by the axes of co-ordinates and a given straight line
- Check whether the number formed by concatenating two numbers is a perfect square or not
- Program for Area Of Square
- Area of square Circumscribed by Circle
- Area of a Circumscribed Circle of a Square
- Sum of Area of all possible square inside a rectangle
- Program for Area Of Square after N-th fold
- Area of a square from diagonal length
- Area of a leaf inside a square
- Area of the Largest square that can be inscribed in an ellipse
- Area of a largest square fit in a right angle triangle

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.