C++ Program to calculate a^b.

C++ Program to calculate a^b.



#include<iostream.h>
#include<conio.h>
int pwr(int,int);
void main()
{
clrscr();
int a,d;
cout<<"Enter first number: ";
cin>>a;
cout<<"Enter second number: ";
cin>>d;
cout<<"A^B: "<<pwr(a,d);
getch();
}

pwr(int a,int d)
{
int i,b=1;
for(i=1;i<=d;i++)
b=b*a;
return b;
}


Learn More :