正方形是在一个平面上的平面形状,由四个角的四个点定义。一个正方形具有四个等长的边和四个直角(90度角)的角。正方形是一种矩形。
例子 :
Input : 4
Output :16
Input :8
Output :64
公式
C++
// CPP program to find
// the area of the square
#include
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
Javascript
输出 :
16