# include <iostream.h>
# include<conio.h>
int power ( int x, int y);
void main( )
{
int x, y ;
cout<< "\n Enter value of x & y : ";
cin>>x>>y;
cout<<"\n"<<x<<" ^ "<<y<<" = "<< power(x,y);
}
int power (int x, int y) // Recursive power function
{
if (y ==1)
return x;
else
return(x * power(x,y-1));
}
0 comments:
Post a Comment