PROGRAM FOR POWER using RECURSION.
#include <iostream>
#include <conio.h>
using namespace std;
long Power(int A, int B);
int main()
{
int No, Pow;
cout << "Enter Any Number: ";
cin >> No;
cout << "Power of Number is: ";
cin >> Pow;
cout << "\nResult is: " << Power(No, Pow) << endl;
getch();
return 0;
}
long Power(int A, int B)
{
long Result;
if (B == 1)
return A;
Result = A * Power(A, B - 1);
return Result;
}
0 comments:
Post a Comment