Array loop problem which returns the difference between the value with fixed value
I hope I can explain a problem that I've tried to code but having problems with.
I have an array of 20 numeric values and the each value is passed (in a loop) along with a fixed value (1.50) to a function that returns the difference between the two.
I have the function coded and working correctly.
array - 1.50 = 3
array - 1.50 = 2
array - 1.50 = 0.5
This has to be done in the loop until the the program finds the first element in the array with a difference of less than 1.
So for instance in the example above if the value of array = 2. then the loop would stop there as it's the first element in the array with a difference < 1.
I can't get the loop structure coded correcty, I trust I need a while loop and a for loop.
Hope you can see the problem and help if possible. Please let me know if you need clarificatiion.