Saturday, 9 February 2013

Inline function in c++

#include<iostream.h>
#include<conio.h>

inline double cube(const double side)    //inline function
                                         //cube is the name of inline function
                //we simply declare side as constant
                                                            //double is a data type like int,float etc
{                                           //which is used to stoer large real values
return side*side*side;
}

int main()
{
double sidevalue;
cout<<"Enter the side length of your cube: ";
cin>>sidevalue;
cout<<"volume of cube with side "<<sidevalue<<" is "<<cube(sidevalue)<<endl;//recalling inline function
                  //we r passing sidevalue as an argument to side in inline func.
getch();
return 0;
}

0 comments:

Post a Comment