
- C Programming Tutorial
- C - Home
- C - Overview
- C - Environment Setup
- C - Program Structure
- C - Basic Syntax
- C - Data Types
- C - Variables
- C - Constants
- C - Storage Classes
- C - Operators
- C - Decision Making
- C - Loops
- C - Functions
- C - Scope Rules
- C - Arrays
- C - Pointers
- C - Strings
- C - Structures
- C - Unions
- C - Bit Fields
- C - Typedef
- C - Input & Output
- C - File I/O
- C - Preprocessors
- C - Header Files
- C - Type Casting
- C - Error Handling
- C - Recursion
- C - Variable Arguments
- C - Memory Management
- C - Command Line Arguments
- C Programming useful Resources
- C - Questions & Answers
- C - Quick Guide
- C - Useful Resources
- C - Discussion
C Program for Area And Perimeter Of Rectangle
Given a length and breadth of a rectangle we have to find its area and Perimeter.
Rectangle is 2-D figure containing four sides and four angles of 90 degree each. All the sides of rectangle are not equal only the opposite sides of a rectangle are equal. The diagonals in a rectangle also are of the same length.
Below is a diagrammatic representation of rectangle.
Here A represents the breadth and B represents length of the rectangle.
To find the Area of a rectangle the formula is: Length x Breadth
And Perimeter of a rectangle is − 2 x (Length+Breadth).
Examples
Input: 20 30 Output: area of rectangle is : 600 perimeter of rectangle is : 100
Algorithm
START In Function int area(int a, int b) Step 1 -> Declare an integer ‘area’ and store a * b in it Step 2 -> Return area. In Function int perimeter(int a, int b) Step 1-> Declare an integer ‘perimeter’ and store 2*(a + b) in it Step 2-> Return perimeter In int main() Step 1 -> Declare two integers ‘length’, ‘breadth’ Step 2 -> Print area(length,breadth) Step 3 -> Print perimeter(length, breadth); STOP
Example
#include<stdio.h> //function to calculate area int area(int a, int b) { int area = a * b; return area; } //function to calculate perimeter int perimeter(int a, int b){ int perimeter = 2*(a + b); return perimeter; } int main(){ int length= 20; int breadth = 30; printf("area of rectangle is : %d
",area(length,breadth)); printf("perimeter of rectangle is : %d",perimeter(length, breadth)); return 0; }
Output
area of rectangle is : 600 perimeter of rectangle is : 100
- Related Articles
- C++ Program to get minimum perimeter of rectangle whose area is n
- Maximum area of rectangle possible with given perimeter in C++
- Program to find Perimeter / Circumference of Square and Rectangle in C++
- What is rule for perimeter of rectangle and square?
- Calculate the area and perimeter of the following shapes:Q.1 Calculate the area of Square and rectangleQ.2 Calculate perimeter of Square and rectangle."\n
- Program to calculate area and perimeter of equilateral triangle in C++
- Program to calculate area and perimeter of Trapezium
- C++ Perimeter and Area of Varignon’s Parallelogram
- Program to find the Area and Perimeter of a Semicircle in C++
- The area of rectangle is 120 metre square and its breadth is 8 metre. Find the length of the rectangle and perimeter of the rectangle.
- Program to calculate area and perimeter of equilateral triangle
- Java Program to Find the Perimeter of a Rectangle
- Swift Program to Find the Perimeter of a Rectangle
- Kotlin Program to Find the Perimeter of a Rectangle
- Find the area and perimeter of the rectangle, if length $=46 cm$ and breadth $=25 cm$

Advertisements