C Program to Calculate Area & Perimeter of the Rectangle

This C program calculates the area and perimeter (circumference) of the rectangle. The length and breadth of a rectangle are given by user.

Following formula are used to clculate area and perimeter of rectangle:

Area of Rectangle = length * breadth

Perimeter of Rectangle = 2 (length + breadth)

C Source Code: Area & Perimeter of Rectangle


#include<stdio.h>
#include<conio.h>

int main()
{
    /* Declaring variables */
    float length, breadth, area, perimeter;

    /* Reading length and breadth from user */
    printf("Enter length of the rectangle = ");
    scanf("%f", &length);
    printf("Enter breadth of the rectangle = ");
    scanf("%f", &breadth);

    /* Calculating area and perimeter */
    area = length * breadth;
    perimeter = 2 * (length * breadth);

    /* Displaying result */
    printf("Area of rectangle = %f", area);
    printf("\nPerimeter of rectangle = %f", perimeter);

    return 0;
}

Output

Enter length of the rectangle = 23
Enter breadth of the rectangle = 17
Area of rectangle = 391.000000
Perimeter of rectangle = 782.000000