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);
}
-
Next Create a C++ class overload to perform following functions: float area(float,float,float) – returns the area of cone. float area(float, float) – returns the area of sphere. float area( int) – returns the area of circle.
-
Previous Write c program to create array of student names and search given name is found or not.
0 Comments