Q:

Program to find the area of the square

belongs to collection: Basic Programs

0

Area of the square is the amount of space occupied by a square. Square refers to a plane figure with four equal straight sides and four right angles.

Formula

area = width × height
Area of square will be calculated as : 
area = side2
since width = height; 

Algorithm

  1. Define the height of any one side of the square as 's.'
  2. Calculate the area of the square by multiplying s with s
  3. Define the area_square as the area of the square.

Complexity

O(1)

Input:

a = 13  

Output:

Area of Square = a2 
               = 132
               = 169

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

C Program

#include <stdio.h>  
int main()  
{  
   int s=13;  
   int area_square=s*s;  
   printf("Area of the square=%d",area_square);  
}  

 

Output:

Area of the square=169    

 

PHP Program

<?php    
   $s=13;  
   $area_square=$s*$s;  
    echo "Area of the square=";  
    echo $area_square;  
?>

    

Output:

Area of the square=169  

 

Java Program

public class shpere{      
    public static void main(String args[])  
    {  
    int s=13;  
   int area_square=s*s;  
        System.out.println("Area of the square="+area_square);  
     }  
}  

 

Output:

Area of the square=169

 

C# Program

using System;                 
public class Program  
{  
    public static void Main()  
    {  
int s=13;  
   int area_square=s*s;  
   Console.WriteLine("Area of the square="+area_square);  
    }  
}

  

Output:

Area of the square=169

 

Python Program

s=13  
area_square=s*s  
print("Area of the square="+str(area_square))  

 

Output:

Area of the square=169  

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Program to find the surface area of the sphere... >>
<< Program to find the area of the parallelogram...