I need help finding numbers within an interval.

I have to follow by this function and im lost as to what to do next.

int nrVal = findNrGPA(double array[], int length, double minlimit, double maxlimit)

{

___while (int i=0; i++; array[] < maxlimit)

___{

_______if (minlimit > 1)

___}

}

note the interval is from a gpa of 1.0 to 4.0

assuming the array has already been sorted

if someone can help explain step by step that would be much appreciated

I have to follow by this function and im lost as to what to do next.

int nrVal = findNrGPA(double array[], int length, double minlimit, double maxlimit)

{

___while (int i=0; i++; array[] < maxlimit)

___{

_______if (minlimit > 1)

___}

}

note the interval is from a gpa of 1.0 to 4.0

assuming the array has already been sorted

if someone can help explain step by step that would be much appreciated

Last edited on

Not sure what you're trying to do. Is this an array of grades, and you're trying to calculate a GPA?

Your code has quite a bit of syntax errors, but the logic could be something like this

- Pass to the function all the arguments it needs: an array of grades, an array where to store the grades within the interval, the lenght of the array, the lower bound and the upper bound of the interval (there is also another way to do this but it involves dynamic memory allocation, which is a bit harder)

- Check every element of the grades array. If they are within the interval copy them to the valid grades array

- Pass to the function all the arguments it needs: an array of grades, an array where to store the grades within the interval, the lenght of the array, the lower bound and the upper bound of the interval (there is also another way to do this but it involves dynamic memory allocation, which is a bit harder)

- Check every element of the grades array. If they are within the interval copy them to the valid grades array

the array is declared in the int main()

the array has randomized grades with a size of 10 values

// findNrGPARange = find the number of GPA values in the array

// that are between a range of values

i'm guessing i have to create a range for the values to be found in

the range has to be within 1.0 and 4.0

i hope this helps

the array has randomized grades with a size of 10 values

// findNrGPARange = find the number of GPA values in the array

// that are between a range of values

i'm guessing i have to create a range for the values to be found in

the range has to be within 1.0 and 4.0

i hope this helps

I still have no idea what you're doing. If you're looking for GPA of all values in the array, just iterate through adding them all together, then divide by 4.

im telling the array that i need to find certain values within a set range of the array. So i have to create a range for the function to search into to. basically i'll search for a value in the array but i need to create a range for my search function to search into. this range has to be from 1.0 to 4.0. im lost on how to create this range of the array

If it's sorted, all you have to pull the numbers from the beginning to the first number > 4.0. Assuming it's sorted lowest to highest. If not, just do the reverse of that. Nothing fancy needs to be done.

If it's not sorted, just iterate through the array and check each number to see if it falls within that range (compound conditional).

If it's not sorted, just iterate through the array and check each number to see if it falls within that range (compound conditional).

Topic archived. No new replies allowed.