Big Moose Saloon
 Search | Java FAQ | Recent Topics Register / Login

Please explain how does this program works?(arrays)

beu curt
Greenhorn

Joined: Jan 16, 2010
Posts: 18
HI!

So this program find out which is the largest among 10 inputted numbers.
Can you please stimulate how this program works.
What if I input numbers from 3-12? How will this program work that out?
How would you explain it to a beginner?

Thank you
Siddhesh Deodhar
Ranch Hand

Joined: Mar 05, 2009
Posts: 117
# if((counter == 0)|| (num[counter]>max))
# max= num[counter];

Here is its heart. suppose you enre numbers 4,5,8,6,9,7,8,33,7,9
First time counter == 0 so max is 4
Second time counter == 0 is false, so it goes for next condition num[counter]>max) i.e. 5>4.. YES. so make max= 5

program proceeds same way and prints maximum value at the end.

Good, Better, Best, Don't take rest until, Good becomes Better, and Better becomes Best.
Sidd : (SCJP 6 [90%] )

I agree. Here's the link: http://aspose.com/file-tools

subject: Please explain how does this program works?(arrays)