Howdy readers, today you will learn **how to write a C++ program to calculate the area of a rectangle**.

The area of a rectangle **( A)** is the product of its length

**‘**and width

*l*’**‘**. So, the area of the rectangle is:

*b*’**Area of Rectangle (A) = Length (a) x Width (b)**.

This program uses the above formula to find the area of a rectangle.

So, without any delay, let’s begin this tutorial.

**C++ Program to Calculate Area of Rectangle**

**C++ Program**

// C++ Program to Calculate Area of Rectangle #include <iostream> using namespace std; int main(){ int length, breadth; float area; // Taking input cout << "Enter the length of the rectangle: "; cin >> length; cout << "Enter the breadth of the rectangle: "; cin >> breadth; // Calculating area of rectangle using formula area = length * breadth; // Display area cout << "The area of the rectangle is: " << area << endl; return 0; }

**Output**

Enter the length of the rectangle: 12 Enter the breadth of the rectangle: 16 The area of the rectangle is: 192

**Explanation**

int length, breadth; float area;

In this program, we have declared two int data type variables and one float data type variable named ** length**,

**and**

`breadth `

**respectively.**

`area `

cout << "Enter the length of the rectangle: "; cin >> length; cout << "Enter the breadth of the rectangle: "; cin >> breadth;

The user is asked to enter the value of the length and breadth of the rectangle.

area = length * breadth;

The area of the rectangle is obtained using the formula: ** A = l x b**, where

**is the**

*‘l’***length**and

**is the**

*‘b’***breadth**of the rectangle.

cout << "The area of the rectangle is: " << area << endl;

After that, the area of the rectangle is printed on the screen using the **cout** statement.

**Conclusion**

Today you learned **how to write a C++ program to calculate the area of a rectangle**.

Don’t forget to ask your queries in the comment section.

Thanks for reading.

Happy Coding!!

**Also Read:**

**C++ Program to Calculate Area of Square****C++ Program to Convert Fahrenheit to Celsius****C++ Program to Find Quotient and Remainder****C++ Program to Find the Square Root of a Number****C++ Program to Calculate Simple Interest Using Function**