Hello guys, i tried to write a code which returns the longest name in an array but i have 1 problem:
1.how do i set the "max" value that the compiler will read it and won't say " variable max might not have been initialized "?
My suggestions for you is that you are going to be going through the array in linear time (sequentially). What I suggest is that you initialize the first value of the array to be the largest item prior to iterating through the array. Once you iterate or loop through the array, check every value against the max value and if it is larger than the max value, then that value would become the new max value. Good luck!
Let's go to the waterfront with this tiny ad:
how do I do my own kindle-like thing - without amazon