Program for Area Of Square after N-th fold Last Updated : 21 Jun, 2022 Comments Improve Suggest changes Like Article Like Report 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 N and number of folds F . 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. Examples: Input : N = 4, F = 2 Output : 2 Explanation: 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 = 6 Output : 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; } 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 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 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 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 ?> JavaScript <script> // Javascript program to find // the area of the square // Function to calculate area of square after // given number of folds function areaSquare( side, fold) { var area = side * side; return (area * 1.0 )/ (Math.pow(2, fold)); } // Driver Code var side = 4, fold = 2; document.write(areaSquare(side, fold)); // This code is contributed by akshitsaxenaa09. </script> Output: 4 Time complexity : O(logn) Auxiliary Space : O(1) Comment More infoAdvertise with us Next Article Program for Surface Area of Octahedron S Sanjit_Prasad Follow Improve Article Tags : Mathematical Geometric DSA school-programming Practice Tags : GeometricMathematical Similar Reads Program to find the area of a Square What is a square ? 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 but with all sides equal. Formula : Area = side * side Examples: In 3 min read Program for Area Of Square 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. Examples : Input : 4 Output :16 Input :8 Output :64 Formula Area = side*side C++ // 2 min read Program for Surface Area of Octahedron Given the sides of Octahedron then calculate the surface area. Examples: Input : 7 Output : 169.741 Input : 9 Output : 280.59 An regular octahedron has eight faces, which are all in the shape of equilateral triangles.The area of an octahedron is 2 multiplied by the length of an edge squared multipli 2 min read Program to calculate area of an Circle inscribed in a Square Given the side of a square. The task is to find the area of an inscribed circle in a square.Examples: Input : a = 8 Output : Area of an inscribed circle: 50.24 Input : a = 12.04 Output : Area of an inscribed circle: 113.795 Given a square i.e. all sides of a square are of equal length and all four a 4 min read Area of a square from diagonal length Given an number d which is length of diagonal of a square, find its area. Examples: Input : d = 10 Output : Area = 50 Input : d = 12.2 Output : Area = 74.42 Area of a square can be computed as (d * d)/2. Please see below image for details. C++ // C++ Program to find the area of square // when its di 3 min read Puzzle | Program to find number of squares in a chessboard You are provided with a chessboard and are asked to find the total number of squares in it. A chessboard is a board with 8 x 8 grids in it, as represented below. Examples: Input: n = 2Output: 5 (4 squares of 1 unit + 1 square of 2 units)Explanation: Total number of square = 5 (4 squares with side of 3 min read Like