On Oct 8, 6:14 am, Pravglad <[email protected]> wrote: > if((counter == 0)||(num[counter] > max)) > max = num[counter]; > > to find greatest number.. > > why do we use || operator here??i am lost
Please Pravgad, could you put a meaningful subject to your posts. Because the ones you use defeats the search capabilities of the forum. That said, the first part of the if is meant for the first time you enter the loop, it will set the value of max to the first value encountered. After that the loop will use the second part of the loop to test if the value of the counter is higher than the max value. That is progressively you will find the max value. The best way to see how it works is to put a break point on the if line in your program and debug it, that way you will see how the value of max change through the loop. Michèle Garoche -- To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/javaprogrammingwithpassion?hl=en
