Advertisement
mobi34

Funkcja C++

Feb 4th, 2021
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.62 KB | None | 0 0
  1. zad 1
  2. #include <iostream>
  3.  
  4. using namespace std;
  5. int SUMA(int a, int b)
  6. {
  7.     return a+b
  8. }
  9. int ()
  10. {
  11.     cout << "Hello world!" << endl;
  12.     return 0;
  13. }
  14.  
  15.  
  16. zad 2
  17. #include <iostream>
  18.  
  19. using namespace std;
  20.  
  21. int x ;
  22.  
  23. int WARTOSC_BEWZGLENDNA (int x)
  24. {
  25.     if (x < 0)
  26.     {
  27.         x = x * (-1) ;
  28.  
  29.     }
  30.    return x ;
  31. }
  32.  
  33. int main()
  34. {
  35.     cin >> x ;
  36.     cout << WARTOSC_BEWZGLENDNA(x);
  37.     return 0;
  38. }
  39.  
  40. zad 3
  41.  
  42. #include <iostream>
  43.  
  44. using namespace std;
  45.  
  46. bool CZY_PARZYSTA(int a)
  47. {
  48.     if(a%2==0)
  49.     {
  50.         return true;
  51.     }
  52.      else return false;
  53. }
  54.  
  55. int main()
  56. {
  57.      cout<<CZY_PARZYSTA(20);
  58.     return 0;
  59. }
  60.  
  61.  
  62. zad 4
  63.  
  64.  
  65. #include <iostream>
  66.  
  67. using namespace std;
  68.  
  69.  
  70. int x ;
  71. char z ;
  72. void szlaczek ()
  73. {
  74.     for (int i = 0 ; i<x; i++)
  75.     {
  76.         cout << z ;
  77.     }
  78. }
  79. int main()
  80. {
  81.     cout << "Podaj znak "  ;
  82.     cin >> z ;
  83.     cout << "Jak dlugi ma byc szlaczek " ;
  84.     cin >> x ;
  85.  
  86.     szlaczek () ;
  87.     return 0 ;
  88. }
  89.  
  90.  
  91. zad 9
  92.  
  93.  
  94. #include <iostream>
  95.  
  96. using namespace std;
  97.  
  98. void dzielnik (int n )
  99. {
  100.     for (int i= n ; i<=n ;i++)
  101.     {
  102.         if(n%1==0)
  103.             cout << i << endl ;
  104.     }
  105. }
  106.  
  107. int main ()
  108. {
  109.     count >> "podaj liczbe naturalnom" ;
  110.     cin >> n ;
  111.      dzielnik (84) ;
  112.      return 0;
  113. }
  114.  
  115.  
  116.  
  117. zad 5
  118.  
  119.  
  120. #include <iostream>
  121.  
  122. using namespace std;
  123.  
  124. int potega(int x, int y)
  125. {
  126.     int u=1;
  127.     for(int i =1; i<=y;i++)
  128.     {
  129.         u= u*x ;
  130.     }
  131.  
  132.     return u;
  133. }
  134. int main ()
  135. {
  136.   int x,y ;
  137.   cout <<"Podaj x " ;
  138.   cin >> x ;
  139.   cout <<"podaj y  " ;
  140.   cin >>y ;
  141.   cout << "Wynik to "<< potega (x,y) ;
  142.   return 0;
  143. }
  144.  
  145.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement