I'm posting this here because I'm unable to fathom why is sum equal to zero when running this simple yet wrong program. Does this kind of problem have anything to do with addresses?
#include <iostream>
using namespace std;
void upis(int n, int m, int pp[]) {
do {
cin >> n >> m;
} while(n > 20 || n < m);
for(int i = 1; i <= n; i++) {
do {
cin >> pp[i];
} while(0 > pp[i] || pp[i] > 1000000);
}
}
int suma(int n, int pp[]) {
int sum = 0;
for(int i=1; i<=n; i++) {
sum += pp[i];
}
return sum;
}
int main() {
int n, m, pp[n];
upis(n, m, pp);
cout << suma(n, pp);
return 0;
}