Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- void wypelnij(int a,int tab[])
- {
- for(int i=0;i<a;i++)
- { cout<<"Wpisz "<<i+1<<" element tablicy: ";
- cin>>tab[i];}
- }
- void wyswietl(int a,int tab[])
- {
- cout<<"Podane elementy to: ";
- for(int i=0;i<a;i++)
- {
- cout<<tab[i];
- if(i==a-1)
- {cout<<"."<<endl;}
- else
- {cout<<", ";}}}
- void suma(int a,int tab[])
- { int s=0;
- for(int i=0;i<a;i++)
- {s=s+tab[i];}
- cout<<"Suma elementow tablicy wynosi: "<<s<<"."<<endl;}
- int main()
- {int a;
- cout<<"Podaj rozmiar tablicy: ";
- cin>>a;
- int tab[a];
- wypelnij(a,tab);
- wyswietl(a,tab);
- suma(a,tab);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement