Dremendo Tag Line

Calculate area of a rectangle in C++

cin - Question 12

In this question, we will see how to input length and breadth of a rectangle in C++ programming using the cin statement and find its area. To know more about cin statement click on the cin statement lesson.

Q12) Write a program in C++ to input length and breadth of a rectangle and find its area.

Formula: area = length * breadth

Program

#include <iostream>
#include <conio.h>

using namespace std;

int main()
{
    int l,b,a;
    cout<<"Enter length of a rectangle ";
    cin>>l;
    cout<<"Enter breadth of a rectangle ";
    cin>>b;
    a=l*b;
    cout<<"Area="<<a;
    return 0;
}

Output

Enter length of a rectangle 10
Enter breadth of a rectangle 5
Area=50
video-poster