Â
In this, we are going to see how to find Area of Rectangle using C++ program.
The formula to calculate is,
Area of Rectangle = length * breadthÂ
The Code given below can be used in Turbo C++ Compiler.
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
float area, length, breadth;
cout<<"This program is for Area of Rectangle\n";
cout<<"Enter the length and breadth of the rectangle\n";
cin>>length>>breadth;
// formula for area of rectangle is length x breadth
area = length*breadth;
cout<<"The Area of the rectangle with length "<<length<<" and breadth "<<breadth<<" is = "<<area<<" sq units";
getch();
}
The Code given below can be used in g++/gcc Compiler.
#include<iostream>
using namespace std;
int main()
{
float area, length, breadth;
cout<<"This program is for Area of Rectangle\n";
cout<<"Enter the length and breadth of the rectangle\n";
cin>>length>>breadth;
// formula for area of rectangle is length x breadth
area = length*breadth;
cout<<"The Area of the rectangle with length "<<length<<" and breadth "<<breadth<<" is = "<<area<<" sq units";
return 0;
}
#ENJOY CODING
Post a Comment
FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP