Advertisement
Kacper_Michalak

Zadanie funkcje 5

Jan 23rd, 2021 (edited)
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.41 KB | None | 0 0
  1.  
  2. #include <iostream>
  3. using namespace std;
  4.  
  5. int POTEGA(int x, int y)
  6. {
  7.     int wynik=1;
  8.     if (y == 0)
  9.     {
  10.         return 1;
  11.     }
  12.     else
  13.     {
  14.         for (int i = 0; i < y; i++)
  15.         {
  16.             wynik = wynik * x;
  17.         }
  18.         return wynik;
  19.     }
  20.    
  21.  
  22. }
  23.  
  24. int main()
  25. {
  26.     cout << POTEGA(5, 4) << endl;
  27.     cout << POTEGA(10, 2) << endl;
  28.     cout << POTEGA(3, 1) << endl;
  29.  
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement