Program for Area Of Square Last Updated : 16 Feb, 2023 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. Examples : Input : 4 Output :16 Input :8 Output :64 Formula Area = side*side C++ // CPP program to find // the area of the square #include <iostream> using namespace std; int areaSquare(int side) { int area = side * side; return area; } // Driver Code int main() { int side = 4; cout << areaSquare(side); return 0; } Java // Java program to find // the area of the square import java.util.*; class GFG { static int areaSquare(int side) { int area = side * side; return area; } // Driver Code public static void main(String[] args) { int side = 5; System.out.println(areaSquare(4)); } } Python3 # Python3 code to find # the area of the square def areaSquare( side ): area = side * side return area # Driver Code side = 4 print(areaSquare(side)) # This code is contributed # by "Sharad_Bhardwaj". C# // C# program to find // the area of the square using System; class GFG { static int areaSquare(int side) { int area = side * side; return area; } // Driver code public static void Main() { int side = 4; Console.WriteLine(areaSquare(side)); } } // This code is contributed by vt_m PHP <?php // PHP program to find // the area of the square function areaSquare($side) { $area = $side * $side; return $area; } // Driver Code $side = 4; echo(areaSquare($side)); // This code is contributed by Ajit. ?> JavaScript <script> // Javascript program to find // the area of the square function areaSquare(side) { let area = side * side; return area; } // Driver Code let side = 4; document.write(areaSquare(side)); // This code is contributed by Mayank Tyagi </script> Output : 16 Time complexity : O(1) Auxiliary Space : O(1) . Comment More info A Ajay Puri Improve Article Tags : Geometric DSA Basic Coding Problems Inautix Explore DSA FundamentalsLogic Building Problems 2 min read Analysis of Algorithms 1 min read Data StructuresArray Data Structure 3 min read String in Data Structure 2 min read Hashing in Data Structure 2 min read Linked List Data Structure 2 min read Stack Data Structure 2 min read Queue Data Structure 2 min read Tree Data Structure 2 min read Graph Data Structure 3 min read Trie Data Structure 15+ min read AlgorithmsSearching Algorithms 2 min read Sorting Algorithms 3 min read Introduction to Recursion 14 min read Greedy Algorithms 3 min read Graph Algorithms 3 min read Dynamic Programming or DP 3 min read Bitwise Algorithms 4 min read AdvancedSegment Tree 2 min read Binary Indexed Tree or Fenwick Tree 15 min read Square Root (Sqrt) Decomposition Algorithm 15+ min read Binary Lifting 15+ min read Geometry 2 min read Interview PreparationInterview Corner 3 min read GfG160 3 min read Practice ProblemGeeksforGeeks Practice - Leading Online Coding Platform 6 min read Problem of The Day - Develop the Habit of Coding 5 min read Like