# C Program to Calculate Area and Perimeter of Square and Rectangle

## Calculate Arean and Perimeter of Square and Rectangle in C

To calculate area and perimeter of square and rectangle in C programming, you have to ask to the user to enter length and breadth of rectangle and side length of square and make two variable, one for area and one for perimeter for each to perform mathematical calculation and display the result

## Calculate Area and Perimeter of Rectangle in C

Following C program ask to the user to enter the length and breadth of the rectangle to calculate and display the area and perimeter of the rectangle:

## C Programming Code to Calculate Area and Perimeter of Rectangle

```#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int len, bre, peri, area;
printf("Enter length and breadth of the rectangle :");
scanf("%d%d",&len,&bre);
area=len*bre;
peri=(2*len)+(2*bre);
printf("Area = %d\tPerimeter=%d",area,peri);
getch();
}```

When the above c program is compile and executed, it will produce the following result: ## Calculate Area and Perimeter of Square in C

Following c program ask the user to enter the side of a square to calculate and display the area and perimeter of the square:

## C Programming Code to Calculate Area and Perimeter of Square

```#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int side, peri, area;
printf("Enter length of a side of square :");
scanf("%d",&side);
area=side*side;
peri=4*side;
printf("Area = %d\tPerimeter=%d",area,peri);
getch();
}```

When the above c program is compile and executed, it will produce the following result: ### Same Program in Other Programming Language

You may also like same program in other programming languages:

Tools
Calculator

Quick Links
Signup - Login - Give Online Test