Write a C++ program to find area and volume of cylinder 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.h>
#include<iostream.h>
inline float area(float r,float h,float p=3.142) //inline function
{
return ((2*p*r*h)+(2*p*r*r));
}
inline float volume(float r,float h,float p=3.142)
{
return(p*r*r*h);
}
int main()
{
int r,h; //r=radius , h=height
cout<<"Enter the radius: ";
cin>>r;
cout<<"Enter the height: ";
cin>>h;
cout<<"Area of cylinder : "<<area(r,h)<<endl;
cout<<"Volume of cylinder : "<<volume(r,h);
getch();
return(0);
}
0 Comments