Advertisement
Spocoman

06. Math Power

Oct 26th, 2023
607
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.32 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int mathPower(int b, int e) {
  6.     int result = 1;
  7.  
  8.     for (int i = 0; i < e; i++) {
  9.         result *= b;
  10.     }
  11.  
  12.     return result;
  13. }
  14.  
  15. int main() {
  16.     int base, exponent;
  17.     cin >> base >> exponent;
  18.  
  19.     cout << mathPower(base, exponent) << endl;
  20.  
  21.     return 0;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement