5. C Program to find Area and Perimeter of a Square.
How does this program work?
- In this programme you will learn about how to calculate Area and Perimeter of a Square.
- This programme requires the user input to enter the Length of the Square side.
- This programme perform mathematical calculation and display the result using C language.
Here is the code
#include <stdio.h>
int main(void)
{
int a,b,c; //Initialise the variables
printf("Enter length of the square side\n");
scanf ("%d",&a); //To store the enter value
b=a*a; //Equation for area of a square
c=4*a; //Equation for Perimeter of a square
printf("Area of square = %d\n",b);
printf("Perimeter of square= %d\n",c);
return 0;
}