10-22-2017 06:23 PM
question is:
Have a while loop iterate over elements in “Loop 2 In” and check if the element is equal to 0 if it is end the loop and output the element #(loop iteration) where the first 0 occurs. I.E. input [44,2,0,12] should output 2 because the 0 element is 44, the 1st element is 2 and the 2nd element is 0. If there is no 0’s in your loop it will take the first blank element as a zero and claim that to be the first 0 in the array.
and all i really have is,
Please help what to do..I am stuck on this question for awhile!!
10-22-2017 06:31 PM - edited 10-22-2017 06:31 PM
You could use Search 1-D array for the zero value.
10-22-2017 06:53 PM
In the real world, we would just use Search 1D Array. In situations where I am looking for a specific value in an array of clusters (looking for the element with a certain value in the cluster), then I have used a FOR loop with the Loop Terminator turned on. Just autoindex on the array and do the comparison inside of the loop. If your comparison is TRUE, the loop stops. I also tend to output the cluster (tunnel set to Last Value) so then I have the needed value. In your case, you use the i terminal instead.
10-22-2017 07:24 PM
It is the solution.
Ing. Ovidio Torres (El Salvador).
10-23-2017 01:25 AM
As its just an a Numeric array without decimal points, Use search 1D Array where you will get the output as First found index and if its not you will get the output as -1
10-23-2017 02:52 AM
Yet another homework question...
10-23-2017 09:56 AM
As a side note: avoid using comparisons with DBL numbers. You may not get what you expect.
0.0000000000000001 does NOT equal 0