C program to calculate perimeter and area of a square. Take sides of square as input.
// C program to calculate perimeter and area of a square
#include <stdio.h>
int main(){
float sideOfSquare, areaOfSquare, perimeterOfSquare;
printf(“Enter length of side of squaren”);
scanf(“%f”, &sideOfSquare);
// Perimeter of Square = 4*Side
perimeterOfSquare = 4*sideOfSquare;
printf(“Perimeter of square : n%f”, perimeterOfSquare);
// Area of Square = Side*Side
areaOfSquare = sideOfSquare * sideOfSquare;
printf(“nArea of square : n%f”, areaOfSquare);
return 0;
}
Output: