fork download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. double potega(double liczba, unsigned int potega);
  6.  
  7. int main()
  8. {
  9. double a = 2.0, w;
  10.  
  11. w = potega(a, 3); // 1
  12.  
  13. cout << a << " do potegi 3 to " << w << endl;
  14.  
  15. cout << a << " do potegi 4 to " << potega(a, 4) << endl; // 2
  16.  
  17. cout << "3 do potegi 2 to " << potega(3, 2) << endl; // 3
  18.  
  19. return 0;
  20. }
  21.  
  22. double potega(double liczba, unsigned int potega)
  23. {
  24. double wynik = 1;
  25.  
  26. for (unsigned int i = 1; i <= potega; ++i)
  27. wynik *= liczba;
  28.  
  29. return wynik;
  30. }
Success #stdin #stdout 0.01s 5264KB
stdin
Standard input is empty
stdout
2 do potegi 3 to 8
2 do potegi 4 to 16
3 do potegi 2 to 9