Write a C++ program to find area and perimeter of rectangle using Inline function.
//Note: If you are not using Borland or Turbo C then add the following line after header files :
//using namespace std;
#include<conio>
#include<iostream>
inline float area(float l,float h) // inline function
{
return(l*h); // formula of area of rectangle
}
inline float peri(float l,float h) // inline function
{
return(2*l+2*h); // formula of perimeter of rectangle
}
int main()
{
float l,h; // l=length , h=height
cout<<"\nEnter value of length(l): ";
cin>>l;
cout<<endl;
cout<<"\nEnter value of height(h): ";
cin>>h;
cout<<"\nArea of rectangle: "<<area(l,h);cout<<endl;
cout<<"\nPerimeter of rectangle :"<<peri(l,h);cout<<endl;
getch();
return(0);
}
0 Comments