fork download
  1. #include<iostream>
  2. using namespace std;
  3. int pow(int, int);
  4. int main()
  5. {
  6. int x,p,ans;
  7. cout<<"Enter a number";
  8. cin>>x;
  9. cout<<"Enter the power of the number";
  10. cin>>p;
  11. ans=pow(x, p);
  12. cout<<ans;
  13. return 0;
  14. }
  15.  
  16. int pow(int x, int p)
  17. {
  18. int a=1,i;
  19. for(i=0;i<=p;i++)
  20. {
  21. a=a*x;
  22. }
  23. return a;
  24. }
Success #stdin #stdout 0s 16064KB
stdin
12
stdout
Enter a numberEnter the power of the number12