Advertisement
Guest User

Tarikul (Power Function)

a guest
Mar 19th, 2019
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.52 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. long long int power(long long int base, long long int to_the_power)
  5. {
  6.     long long int prod = 1;
  7.     for(long long int i = 1; i <= to_the_power; i++)
  8.     {
  9.         prod = prod * base;
  10.     }
  11.    
  12.     return prod;
  13. }
  14.  
  15. int main ()
  16. {
  17.     long long int base, to_the_power;
  18.     cout << "Enter the base: ";
  19.     cin >> base;
  20.     cout << "Enter the power: ";
  21.     cin >> to_the_power;
  22.     long long int a = power(base, to_the_power);
  23.     cout << base << " to the power " << to_the_power << " = " << a;
  24.    
  25.     return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement