Created
November 10, 2015 17:01
-
-
Save nalin-adh/30a30eebd71eaac046e9 to your computer and use it in GitHub Desktop.
A C++ program to calculate power of base using recursion.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<iostream> | |
#include<conio.h> | |
using namespace std; | |
long int power (float b,int p); | |
int main() | |
{ | |
float x; | |
int y; | |
cout<<"Enter the base value : ";cin>>x; | |
cout<<"\nEnter the power value : ";cin>>y; | |
cout<<"\n\nThe "<<x<<" to the power "<<y<<" is "<<power(x,y); | |
getch(); | |
return(0); | |
} | |
long int power (float b,int p){ | |
if(p==0) | |
return(1); | |
else | |
return(b*power(b,(p-1))); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment