fork download
  1. #include <iostream>
  2. using namespace std;
  3. int power(int x, int y)
  4. {
  5. if (y == 0)
  6. {
  7. return 1;
  8. }
  9.  
  10. else if
  11.  
  12. (y % 2 == 0)
  13.  
  14. return power(x, y / 2) * power(x, y / 2);
  15.  
  16. else{
  17.  
  18. return x * power(x, y / 2) * power(x, y / 2);
  19. }
  20.  
  21. }
  22. int main() {
  23. int x,y;
  24. cout<<"Enter the number of which you wnat mutiple of (x) : "<<endl;
  25. cin>>x;
  26. cout << "Enter the power : " << endl;
  27. cin >> y;
  28.  
  29. cout<<"The answer to your input is : " <<power(x,y);
  30.  
  31. return 0;
  32. }
  33.  
Success #stdin #stdout 0.01s 5504KB
stdin
Standard input is empty
stdout
Enter the number of which you wnat mutiple of (x) : 
Enter the power : 
The answer to your input is : 0