From 5fda8b5f724054ff1505ed26a0a0362632e16e21 Mon Sep 17 00:00:00 2001 From: Naman0929 <73557249+Naman0929@users.noreply.github.com> Date: Wed, 28 Oct 2020 02:03:35 +0530 Subject: [PATCH] pow.cpp wrote a code to find the power of a number using recursion --- Miscellaneous/pow.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 Miscellaneous/pow.cpp diff --git a/Miscellaneous/pow.cpp b/Miscellaneous/pow.cpp new file mode 100644 index 0000000..b7f0373 --- /dev/null +++ b/Miscellaneous/pow.cpp @@ -0,0 +1,27 @@ +#include +using namespace std; +int pow(int a, int b ){ + if(a==0){ + return 0; + } + if(b==0){ + return 1; + } + int x=pow(a,b/2); + x*=x; + if(b%2){ + return x*a; + } + return x; + + +} +int main() { + int a, m; + cout<<"Enter number to find power: "; + cin>>a; + cout<<"Enter power: "; + cin>>m; + cout<