Advertisement
Lukasz_Miskiewicz

s2 zadanie 6

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