Program to find the exponential power of an integer using recursive function in Data Structures (C plus plus)

Program to find the exponential power of an integer using a recursive function in Data Structures (C plus plus)

In this tutorial, we will learn about the Program to find the exponential power of an integer using the recursive function in Data Structures (C++).

#include<iostream>

using namespace std;

main()
{
	long pow(int, int), value, k;
	
	cout<<"Please enter any integer value: "<<endl;
	cin>>value;
	
	cout<<"Please enter value for exponent: ";
	cin>>k;
	
	cout<<pow(value,k);
	
}

long pow(int a, int b)
{
	
	if(b==1)
	return a;
	
	else
	return a*pow(a, b-1);

}

Output:

Program to find the exponential power of an integer using recursive function in Data Structures (C plus plus)
Program to find the exponential power of an integer using the recursive function in Data Structures (C plus plus)

 

Prof.Fazal Rehman Shamil (Available for Professional Discussions)
1. Message on Facebook page for discussions,
2. Video lectures on Youtube
3. Email is only for Advertisement/business enquiries.