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 :
![]()
Examples:
Input : 4 Output :16 Input :8 Output :64
CPP
// CPP program to find the area of a square #include <iostream> using namespace std; // function to find the area int area_fun(int side) { int area = side * side; return area; } // Driver program int main() { int side = 4; int area = area_fun(side); cout << area; return 0; } |
chevron_right
filter_none
Java
// Java program to find // the area of a square class GFG { // function to find the area static int area_fun(int side) { int area = side * side; return area; } // Driver code public static void main(String arg[]) { int side = 4; int area = area_fun(side); System.out.println(area); } } // This code is contributed // by Anant Agarwal. |
chevron_right
filter_none
Python3
# Python program to find # the area of a square # function to find the area def area_fun(side): area = side * side return area # Driver program side = 4area = area_fun(side) print (area) # This Code is Contributed # by Azkia Anam. |
chevron_right
filter_none
C#
// C# program to find // the area of a square using System; class GFG { // function to find the area static int area_fun(int side) { int area = side * side; return area; } // Driver code public static void Main() { int side = 4; int area = area_fun(side); Console.WriteLine(area); } } // This code is contributed by vt_m. |
chevron_right
filter_none
PHP
<?php // PHP program to find the // area of a square // function to find the area function area_fun($side) { $area = $side * $side; return $area; } // Driver program $side = 4; $area = area_fun($side); echo( $area); // This code is contributed // by vt_m. ?> |
chevron_right
filter_none
Output:
16
This article is contributed by Ajay Puri. 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 write comments if you find anything incorrect, or you want to share more information about the topic discussed above..
Recommended Posts:
- Program to find the surface area of the square pyramid
- Program for Area Of Square
- Program for Area Of Square after N-th fold
- Program to calculate area of an Circle inscribed in a Square
- Find the area of the shaded region formed by the intersection of four semicircles in a square
- Program to find the Area of an Ellipse
- Program to find area of a Trapezoid
- Program to find the Area of Pentagon
- Program to find area of a triangle
- Program to find the Area of a Parallelogram
- Program to find area of a circle
- Program to find the Area and Perimeter of a Semicircle
- Program to find the Area and Volume of Icosahedron
- Program to find area of a Circular Segment
- Program to find Perimeter / Circumference of Square and Rectangle
Improved By : vt_m

