C++ Power By Recursion

#include<iostream>
using namespace std;
int anik(int a, int b)
{
    if(b == 0)
        return 1;
    else
        return a*anik(a, b-1);
}
int main()
{
    int n, m;

    cout << "Enter Base : ";
    cin >> n;
    cout << endl;

    cout << "Enter Power : ";
    cin >> m;
    cout << endl;

    cout << n << " to the Power " << m << " :: " << anik(n, m) << endl;

    return 0;
}

Comments