C Program To Find Area and Perimeter of Square

In this article, we are going to write a c program to find area and perimeter of square.

We will make this program in the following way -:

  • C Program To Find Area and Perimeter of Square (Simple Way)
  • C Program To Find Area and Perimeter of Square Using Function

To make this program, we will use the following concept which is given below.

If you do not know about these topics well, then you may not understand this program, so you should know about them in detail from the link given above.

Now without wasting time let’s start programming.

C Program To Find Area and Perimeter of Square

C Program To Find Area and Perimeter of Square

Algorithm

  • Program Start
  • Declare Variables
  • Input side from the User
  • Calculating Area of square
  • Calculating Perimeter of square
  • Display Result
  • Program End

Program

#include<stdio.h>

void main()
{
   int side, aos, per;

   printf("\nEnter the Length of Side : ");
   scanf("%d", &side);

   aos = side * side;
   per = 4*side;
   printf("Area of Square : %d", aos);
   printf("Perimeter of Square : %d", per);

}

Output

Enter the Length of Side : 6

Area of Square : 36
Perimeter of Square : 24

C Program To Find Area and Perimeter of Square Using Function

Algorithm

  • Program Start
  • Declare Variables
  • Input side from the User
  • Calling Function to calculate area of square
  • Calculating Area of square
  • Calling Function to calculate perimeter of square
  • Calculating Perimeter of square
  • Display Result
  • Program End

Program

#include<stdio.h>
void aos(int s)
{
   int area;
   area = s*s;
   printf("Area of Square : %d", area);
}
void pos(int s)
{
    int perimeter;

    perimeter = 4*s;

    printf("\nPerimeter of Square : %d",perimeter);
}
void main()
{
   int side;

   printf("\nEnter the Length of Side : ");
   scanf("%d", &side);

   aos(side);
   pos(side);
}

Output

Enter the Length of Side : 8
Area of Square : 64
Perimeter of Square : 32

Conclusion

So friends, in this article, we have written a c program to find area and perimeter of square in this ways

  • C Program To Find Area and Perimeter of Square (Simple Way)
  • C Program To Find Area and Perimeter of Square Using Function

If you have difficulty to understand any program or have any doubts or questions, then tell me in the comment below.

Jeetu Sahu is A Web Developer | Computer Engineer | Passionate about Coding, Competitive Programming, and Blogging

Leave a Comment

Ads Blocker Image Powered by Code Help Pro
Ads Blocker Detected!!!

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.

Refresh
Powered By
CHP Adblock Detector Plugin | Codehelppro