Hi, well i got a problem, I am trying to fill my array with random numbers.. and i want to make it so that the filling ends as soon as the sum of filled elements in that array exceeds and integer (lets say int i=50; )
Code:
void fillArray() {
srand((unsigned)time(0));
for(int i=0; i<50; i++){
v[i] = (rand()%50);
}
int sum = 0;
for(int a=0; a<50; a++){
sum+=v[a];
}
}
i got the filling and the sum, but when i try to make it in a do-while loop, and compare it with sum i get error, as sum is not defined..etc...