A square is a flat shape, in one plane, defined by four points at the four corners. A square has four sides all of equal length, and four corners, all right angles (90 degree angles). A square is a kind of rectangle.

Given a square of side and number of folds . The task is to find the area of square after **F-th** fold.

The folding of square is as follows:

- In 1st folding, fold the square from left to right side in the form a triangle.
- In 2nd folding, fold the square from up to down side.
- In 3rd folding, again fold the square from left to right side.

and so on.

**Examples:**

Input :N = 4, F = 2Output :2Explanation: Initially square side is 4 x 4 After 1st folding, square side becomes 4 x 2 After 2nd folding, square side becomes 2 x 2 Thus area equals 2 x 2 = 4.Input :N = 100, F = 6Output :156.25

**Approach**:

- Initially calculate the area of the square before folding.
- After each folding, the area of square reduces by half. That is,
**area = area/2**. - So, we finally divide the area of square by pow(2, F)

Below is the implementation of above approach:

## C++

`// CPP program to find ` `// the area of the square ` `#include <bits/stdc++.h> ` `using` `namespace` `std; ` ` ` `// Function to calculate area of square after ` `// given number of folds ` `double` `areaSquare(` `double` `side, ` `double` `fold) ` `{ ` ` ` `double` `area = side * side; ` ` ` ` ` `return` `area * 1.0 / ` `pow` `(2, fold); ` `} ` ` ` `// Driver Code ` `int` `main() ` `{ ` ` ` `double` `side = 4, fold = 2; ` ` ` ` ` `cout << areaSquare(side, fold); ` ` ` ` ` `return` `0; ` `} ` |

*chevron_right*

*filter_none*

## Java

`// Java program to find the area of the square ` `class` `GFG ` `{ ` ` ` ` ` `// Function to calculate area of square ` ` ` `// after given number of folds ` ` ` `static` `double` `areaSquare(` `double` `side, ` ` ` `double` `fold) ` ` ` `{ ` ` ` `double` `area = side * side; ` ` ` ` ` `return` `area * ` `1.0` `/ Math.pow(` `2` `, fold); ` ` ` `} ` ` ` ` ` `// Driver Code ` ` ` `public` `static` `void` `main(String []args) ` ` ` `{ ` ` ` `double` `side = ` `4` `, fold = ` `2` `; ` ` ` ` ` `System.out.println(areaSquare(side, fold)); ` ` ` `} ` `} ` ` ` `// This code is contributed ` `// by aishwarya.27 ` |

*chevron_right*

*filter_none*

## Python3

`# Python3 program to find the area ` `# of the square ` ` ` `# Function to calculate area of ` `# square after given number of folds ` `def` `areaSquare(side, fold) : ` ` ` `area ` `=` `side ` `*` `side ` ` ` `ans ` `=` `area ` `/` `pow` `(` `2` `, fold) ` ` ` `return` `ans ` ` ` `# Driver Code ` `if` `__name__ ` `=` `=` `"__main__"` `: ` ` ` ` ` `side ` `=` `4` ` ` `fold ` `=` `2` ` ` `print` `(areaSquare(side, fold)) ` ` ` `# This code is contributed by Ryuga ` |

*chevron_right*

*filter_none*

## C#

`// C# program to find the area of the square ` `using` `System; ` ` ` `class` `GFG ` `{ ` ` ` `// Function to calculate area of square ` `// after given number of folds ` `static` `double` `areaSquare(` `double` `side, ` ` ` `double` `fold) ` `{ ` ` ` `double` `area = side * side; ` ` ` ` ` `return` `area * 1.0 / Math.Pow(2, fold); ` `} ` ` ` `// Driver Code ` `public` `static` `void` `Main() ` `{ ` ` ` `double` `side = 4, fold = 2; ` ` ` ` ` `Console.Write(areaSquare(side, fold)); ` `} ` `} ` ` ` `// This code is contributed ` `// by Akanksha Rai ` |

*chevron_right*

*filter_none*

## PHP

`<?php ` `// PHP program to find the area of the square ` ` ` `// Function to calculate area of square ` `// after given number of folds ` `function` `areaSquare(` `$side` `, ` `$fold` `) ` `{ ` ` ` `$area` `= ` `$side` `* ` `$side` `; ` ` ` ` ` `return` `$area` `* 1.0 / pow(2, ` `$fold` `); ` `} ` ` ` `// Driver Code ` `$side` `= 4; ` `$fold` `= 2; ` `echo` `areaSquare(` `$side` `, ` `$fold` `); ` ` ` `// This code is contributed by ajit ` `?> ` |

*chevron_right*

*filter_none*

**Output:**

4

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the **DSA Self Paced Course** at a student-friendly price and become industry ready.

## Recommended Posts:

- Program to find the area of a Square
- Program for Area Of Square
- Program to calculate area of an Circle inscribed in a Square
- Program to find the surface area of the square pyramid
- Calculate Volume, Curved Surface Area and Total Surface Area Of Cylinder
- Find area of the larger circle when radius of the smaller circle and difference in the area is given
- Nth Square free number
- Nth non-Square number
- Area of a square from diagonal length
- Area of a Circumscribed Circle of a Square
- Area of square Circumscribed by Circle
- Sum of Area of all possible square inside a rectangle
- Area of a largest square fit in a right angle triangle
- Area of the Largest square that can be inscribed in an ellipse
- Area of a square inscribed in a circle which is inscribed in an equilateral triangle
- Area of a square inscribed in a circle which is inscribed in a hexagon
- Area of a leaf inside a square
- Find the area of the shaded region formed by the intersection of four semicircles in a square
- Find number of square of area Z which can be built in a matrix having blocked regions
- Largest area square in an array when elements can be shuffled

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.