Program to calculate Area and Perimeter of Rectangle using Call by Reference
#include<iostream>
#include<conio.h>
using namespace std;
void area_cal(int length, int breadth, int *
area);
void perimeter_cal(int
length, int breadth, int
*perimeter);
int main()
{
int length = 0, breadth = 0, area = 0, perimeter = 0;
cout
<< "\n\n\t\t\t__ Area and Perimeter
__";
cout
<< "\n\n\n Enter the Length -
";
cin
>> length;
cout
<< "\n\n\n Enter the Breadth -
";
cin
>> breadth;
area_cal(length,
breadth, &area);
perimeter_cal(length,
breadth, &perimeter);
cout
<< "\n\n\n\t\t Area -
" << area << "\t
Perimeter - " << perimeter;
getch();
return 0;
}
void area_cal(int length, int breadth, int
*area)
{
*area =
length * breadth;
}
void perimeter_cal(int
length, int breadth, int
*perimeter)
{
*perimeter
= 2 * (length + breadth);
}
No comments:
Post a Comment