Advertisement
wiktormadera

zad11

Apr 2nd, 2020
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.41 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int SILNIA(int n)
  6. {
  7.     int a,suma=1;
  8.     for(int i=1;i<=n;i++)
  9.     {
  10.         suma=suma*i;
  11.     }
  12.     return suma;
  13. }
  14. int main()
  15. {
  16.     int n;
  17.     cout << "Funkcja silnia. Podaj liczbe: " << endl;
  18.     cin >> n;
  19.     if (n<1)
  20.     {
  21.         cout << "Zle podana liczba.";
  22.     }
  23.     else
  24.     {
  25.     cout << "Silnia wynosi: " << SILNIA(n);
  26.     }
  27.     return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement