Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

for each loop summation


public class Sample {
    public static void main(String[] args) {

        int num[] = { 1, 2, 3, 4, 5 };
        int sum = 0;

        for (int numbers : num) {
            sum = sum + numbers;

        }
        System.out.println("The total sum is " + sum);

    }
}
 
PREVIOUS NEXT
Tagged: #loop #summation
ADD COMMENT
Topic
Name
6+8 =