Get the FREE certificate on C, C++, Java, Python, Perl, PHP, SQL, Linux, Javascript!  

Home C C++ Java Python Perl PHP Spring SQL Javascript Linux

You are here : Home » Solved Programs on C++ » C++ program to find power of any number

C++ program to find power of any number without using pow() function

using namespace std;

unsigned long int integerPower(int base, unsigned int power)
unsigned long int val=  base;

for(unsigned long int i = 0; i< power-1; i ++)
  val = val * base; 

return val;

int main()
int base;
unsigned int power;
unsigned long int val = 0;

cout<<"\n Enter base (non zero) : ";

cout<<"\n Enter power (positive) : ";

val = integerPower(base, power);

cout<<"\n Result is : "<< val;

return 0;