So this code is supposed to take a range from the user and process an array in that range. Then it is supposed to output it backwards and only the positive numbers. I got it to generate an array and process it backwards and print both out. My problem is I can't figure out how to connect the range the user enters with the array. Also it only prints out negative numbers for some reason and that is the opposite of what I'm trying to do. I hope that makes sense. I've been stuck for a while. Any helpful hints you can give me are appreciated!
Also it only prints out negative numbers for some reason
I'm not sure what you're talking about. You fill it with 7 * i, that's what it prints out for me.
As for the range thing -
1 2 3 4 5 6 7 8 9 10 11
int range(int lowest, int highest)
{
staticbool first = true;
if (first)
{
srand(time(NULL));
first = false;
}
return rand() % highest + lowest; // return number between highest and lowest
}
1 2 3
for (int i = 0; i < SIZE; i++) {
test[i] = range(lowest,highest); // fills it with numbers between highest and lowest
}