Write a C++ program to accept length and width of a rectangle. Calculate and display perimeter as well as area of a rectangle by using inline function.
#include<iostream.h>
#include<conio.h>
inline int area(int l,int b)
{
return(l*b);
}
inline int peri(int l,int b)
{
return(2*(l+b));
}
int main()
{
int length,breadth;
clrscr();
cout<<"\n\nEnter the Length of the rectangle:";
cin>>length;
cout<<"\nEnter the Breadth of the rectangle:";
cin>>breadth;
cout<<"\nArea of Rectangle:"<<area(length,breadth);
cout<<"\nPerimeter of Rectangle:"<<peri(length,breadth);
getch();
return 0;
}
#include<iostream.h>
#include<conio.h>
inline int area(int l,int b)
{
return(l*b);
}
inline int peri(int l,int b)
{
return(2*(l+b));
}
int main()
{
int length,breadth;
clrscr();
cout<<"\n\nEnter the Length of the rectangle:";
cin>>length;
cout<<"\nEnter the Breadth of the rectangle:";
cin>>breadth;
cout<<"\nArea of Rectangle:"<<area(length,breadth);
cout<<"\nPerimeter of Rectangle:"<<peri(length,breadth);
getch();
return 0;
}