Construct a C++ program to find the square of a number using default arguments and inline functions
#include<iostream.h>
#include<conio.h>
class power
{
public:
inline int square(int n)
{
return n*n;
}
};
void main()
{
int n,r;
power p;
clrscr();
cout<<“\nEnter the Number: \n” ;
cin>>n;
r=p.square(n);
cout<<“\nSquare of “<<n<<” = “<<r<<endl;
getch();
}
Comments
Leave a comment