Area of square



Area of Square


                    To calculate the area of the square we must know the formula area of the square is  area=side*side
                   To perform this operation in the c language first take the two variables as side and area to display or store the final answer. Then take the input from the user using scanf, then store that values in the side as shown in the code. Pass this variable in formulae to calculate the area of the square. Then the answer is stored in area variable, display area. Refer the following code to calculate the area of the square.  

C language code to calculate the area of square:

#include<stdio.h>

#include<conio.h>

int main()
 {
   int side, area;

   clrscr();

   printf("\nEnter the Length of Side : ");

   scanf("%d",&side);//to accept the side

   area=side*side;//formula to find the area of a square

   printf("\nArea of Square:%d",area);//To display the final answer

   getch();
}
-----------------------------------------------------------------------------------------
Output:
Enter the Length of Side: 5
Area of Square: 25

Area of square Area of square Reviewed by Amit Waghmare on June 21, 2019 Rating: 5

No comments: