PiotrJurek

Zad6

Apr 17th, 2020
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. #include <iostream>
  2. #include <windows.h>
  3.  
  4. using namespace std;
  5.  
  6. void wypelnij(float tab[], int r)
  7. {
  8. for(int i=0; i<r; i++)
  9. {
  10. cout << "Podaj element tablicy:" << endl;
  11. cin >> tab[i];
  12. system("cls");
  13. }
  14. }
  15.  
  16. void wyswietl(float tab[], int r)
  17. {
  18. for(int i=0; i<r; i++)
  19. {
  20. cout << tab[i] << " ";
  21. }
  22. cout << endl;
  23. }
  24.  
  25. float suma(float tab[], int r)
  26. {
  27. float x=0;
  28. for(int i=0; i<r; i++)
  29. {
  30. x = x + tab[i];
  31. }
  32. return x;
  33. }
  34.  
  35. int main()
  36. {
  37. int r;
  38. cout << "Podaj rozmiar tablicy:" << endl;
  39. cin >> r;
  40. float tab[r];
  41. system("cls");
  42. wypelnij(tab, r);
  43. wyswietl(tab, r);
  44. cout << "Suma wynosi: " << suma(tab, r);
  45. return 0;
  46. }
Add Comment
Please, Sign In to add comment