Find Area and Perimeter

Find the area and perimeter of the rectangle. In this function, length and breadth are passed by integer and area and perimeter are passed by reference.

#include<iostream>
using namespace std;
void calRect(int len,int bre,int& ar,int& pm){
	ar = len*bre;
	pm = 2*(len+bre);
}
int main(){
	int l,b;
	int area,perimeter;
	cout<<"Enter length and breadth : "<<endl;
	cout<<"Length : ";
	cin>>l;
	cout<<"Breadth : ";
	cin>>b;
	calRect(l,b,area,perimeter);
	cout<<"Area : "<<area<<endl;
	cout<<"Perimeter : "<<perimeter<<endl;
	return 0;
}
area and perimeter calculated using reference
area and perimeter calculated using reference

One Reply to “Find Area and Perimeter”

Leave a Reply

Your email address will not be published. Required fields are marked *