C program to Calculate area and perimeter of a Rectangle



c-program-to-compute-the-area-and-perimeter-of-a-rectangle

Learn C - C tutorial - c program to compute the area and perimeter of a rectangle - C examples - C programs

C program to Calculate the area and perimeter of a Rectangle

  • A perimeter is a path that surrounds a two-dimensional shape.
  • The perimeter can be used to calculate the length of boundries.
  • The area of a two-dimensional figure describes the amount of surface the shape covers.
  • The formula for the area of a rectangle uses multiplication: length * width = area. A rectangle with four sides of equal length is a square.
  • You measure area in square units of a fixed size. Examples of square units of measure are square inches, square centimeters, or square miles etc.

Sample Code

#include <stdio.h>
int width;
int height;
int area;
int perimeter;
int main()
{
    width= 8;
    height = 6;
    area = width * height;
    printf("area = %d square inches\n", area);
    perimeter = (width * 2) + (height * 2);
    printf("perimeter = %d inches\n", perimeter);
    return(0);
}

Output

area = 48 square inches
perimeter = 28 inches


View More Quick Examples


Related Searches to C program to Calculate area and perimeter of a Rectangle