# C Program to Calculate Area and Perimeter of a Rectangle

• Write a C program to find the area and perimeter of a rectangle.

The rectangle is quadrilaterals(having four sides). All four interior angles of a rectangle are 90.(right angles).
The area of a rectangle is the amount of two-dimensional space inside the boundary on rectangle. The area of a rectangle can be calculated by placing the rectangle over a grid and counting the number of square units it takes to completely fill a rectangle.

The perimeter of a rectangle is the linear distance around the boundary of the rectangle.
In other words, we can think of perimeter of a rectangular surface as the length of fence needed to enclose that rectangular surface, area is the space inside surface. Perimeter is measured in linear units like meter, centimeter, mile etc, whereas area is measured in square units like cm2, Km2 etc. Area of Rectangle
To find the area of rectangle we multiply it's Length and Width.
• Area of Rectangle = L X W
Where,
L is the length of longer side of rectangle
W is the length of smaller side of rectangle
Perimeter of Rectangle
To find the perimeter of a rectangle, we should add the length of all four sides of rectangle. As opposite sides of a rectangle are equal we can calculate perimeter of rectangle as follows:
• Perimeter of Rectangle = 2 X (L + W)
Where,
L is the length of longer side of rectangle
W is the length of smaller side of rectangle

## C Program to find the area of the rectangle

To calculate area of a rectangle, we need length and width of a rectangle. Below program, first takes length and width as input from user using scanf function and stores in 'length' and 'width' variables. To find the area of rectangle we multiple the length and width of rectangle and store area in a floating point variable. At last, it prints the area of rectangle on screen using printf function.

```/*
* C Program to calculate area of a rectangle
*/
#include <stdio.h>
#include <conio.h>

int main(){
float length, width, area;
printf("Enter length of Rectangle\n");
scanf("%f", &length);
printf("Enter width of Rectangle\n");
scanf("%f", &width);
/* Area of Rectangle = Length X Width */
area = length * width;
printf("Area of Rectangle : %0.4f\n", area);

getch();
return 0;
}
```

Program Output
```Enter length of Rectangle
6.5
Enter width of Rectangle
5
Area of Rectangle : 32.5000
```

## C Program to find the perimeter of the rectangle

Below program, first takes length and width as input from user using scanf function and stores in 'length' and 'width' variables. To find the perimeter of rectangle we add the length and width of rectangle and then multiply it with 2(as per formula given above) and store perimeter in a floating point variable. At last, it prints the perimeter of rectangle on screen using printf function.

```/*
* C Program to find perimeter of a rectangle
*/
#include <stdio.h>
#include <conio.h>

int main(){
float length, width, perimeter;
printf("Enter length of Rectangle\n");
scanf("%f", &length);
printf("Enter width of Rectangle\n");
scanf("%f", &width);
/* Perimeter of Rectangle = 2 X(Length + Width) */
perimeter = 2*(length + width);
printf("Perimeter of Rectangle : %0.4f\n", perimeter);

getch();
return 0;
}
```

Program Output
```Enter length of Rectangle
6.5
Enter width of Rectangle
5
Perimeter of Rectangle : 23.0000
```

Properties of Rectangle
• Opposite sides of a rectangle are equal and parallel.
• A rectangle is a special case of parallelogram, where all internal angles are 90 degree and diagonals are equal.
• A rectangle is also a special case of trapezium, where opposite sides are parallel and equal.
• The diagonals of a rectangle bisects each other(in two equal half).
• A square is special case of rectangle where all sides are equal.

Related Topics
 C program to calculate area of a square C program to calculate area of a parallelogram C program to calculate area of a rhombus C program to calculate volume and total surface area of cuboid C program to calculate area of a right angled triangle C program to calculate area of a trapezium C program to calculate volume and total surface area of cone C program to calculate volume and total surface area of cylinder List of all C Programs
{"ft_lang_label":"__label__en","ft_lang_prob":0.78634995,"math_prob":0.99599385,"size":3626,"snap":"2022-27-2022-33","text_gpt3_token_len":821,"char_repetition_ratio":0.23467697,"word_repetition_ratio":0.29641694,"special_character_ratio":0.24048539,"punctuation_ratio":0.11477762,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9996599,"pos_list":[0,1,2],"im_url_duplicate_count":[null,9,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2022-08-17T14:29:16Z\",\"WARC-Record-ID\":\"<urn:uuid:fc0fbb51-1566-4d51-9565-5a4659228e66>\",\"Content-Length\":\"65744\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:fdae9cd7-fd87-407c-8bc4-2884f7b0fdf6>\",\"WARC-Concurrent-To\":\"<urn:uuid:948f4266-e285-4dc4-8e85-575b73dbfd13>\",\"WARC-IP-Address\":\"142.251.16.121\",\"WARC-Target-URI\":\"https://www.techcrashcourse.com/2015/03/c-program-to-calculate-area-of-rectangle.html\",\"WARC-Payload-Digest\":\"sha1:SZNFEG2XKAXR62UZ2BMY6MAKS4ZZQ3D5\",\"WARC-Block-Digest\":\"sha1:TGW2YWGT5FZ2CDCDLZR4L6SEVHTUDKZY\",\"WARC-Identified-Payload-Type\":\"application/xhtml+xml\",\"warc_filename\":\"/cc_download/warc_2022/CC-MAIN-2022-33/CC-MAIN-2022-33_segments_1659882572908.71_warc_CC-MAIN-20220817122626-20220817152626-00656.warc.gz\"}"}