Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- cout << "Inserisci la dimensione dell'array che vuoi usare." << endl;
- const int dim = 100;
- int vet[dim];
- int n;
- int somma;
- do
- {
- cin >> n;
- if (n <= 1 || n >= 100)
- {
- cout << "Inserisci una dimensione tra 1 e 100."<<endl;
- }
- }
- while (n <= 1 || n >= dim);
- for (int i = 0; i<n; i++)
- {
- cout << "Indice " << i <<endl;
- cin >> vet[i];
- cout << "Hai inserito " << vet[i]<<endl;
- somma = somma + vet[i];
- }
- cout << "La somma dei vettori e': " << somma <<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement