Q:

C Program To Find Area and Perimeter of Square

belongs to collection: Basic C Programming Examples

0

you have to 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

All Answers

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

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

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

total answers (1)

Basic C Programming Examples

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
C Program To Find Area and Perimeter of Triangle... >>
<< C Program To Find Area of Rectangle...