Click here to Skip to main content
15,867,686 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Could you please break down the following code? By the way this is being done in Intellij with the jdk 1.8, with the 'import java.util.scanner' line of code.
int sum =0
for (int p = 0; p < 10; p++) {
sum = sum + Array [p];
}

What I have tried:

I'm very new to coding and need help explaining the following code.
Posted
Updated 10-Jan-17 22:01pm

You have an array called Array which contains integer values.
You loop through the first ten elements in the array, using p as an index which contains the value 0 in the first iteration, 1 in the second, and so on up to 9 in the last iteration. In each iteration round the loop you add the value of the current element of Array to a total called sum
 
Share this answer
 
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900