0% found this document useful (0 votes)
38 views2 pages

Int Sum 0 : I 0 I X.length Boolean Test X (I) I I++ II Ciklus

The code defines a class called Gauss I ciklus with a main method. It initializes an integer array x with a length of 101 and populates each element with its index value from 0 to 100 using a for loop. It then initializes a variable sum to 0 and uses another for loop to iterate from 0 to the array length, summing the value of each iteration to the running total of sum. Finally, it prints the final value of sum to the console.

Uploaded by

Goce Stavreski
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as XLSX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
38 views2 pages

Int Sum 0 : I 0 I X.length Boolean Test X (I) I I++ II Ciklus

The code defines a class called Gauss I ciklus with a main method. It initializes an integer array x with a length of 101 and populates each element with its index value from 0 to 100 using a for loop. It then initializes a variable sum to 0 and uses another for loop to iterate from 0 to the array length, summing the value of each iteration to the running total of sum. Finally, it prints the final value of sum to the console.

Uploaded by

Goce Stavreski
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as XLSX, PDF, TXT or read online on Scribd
You are on page 1/ 2

class Gauss I ciklus { public static void main(String[] args) { int[] x = new int[101]; for (int i = 0; i < x.

length; i++)

i=0

i<x.length boolean test x[i] = I 0 0< 101 TRUE x[0] = 0 1<101 TRUE x[1] = 1 101 < 101 FALSE izlez od ciklus sledi int sum = 0; I potoa II ciklus od e = 0; int length x[0] x[1] 101 0 1

i++ 1 2

II ciklus

x[i] = i; int sum = 0; for (int e = 0; e < x.length; e++) sum += e; System.out.println(sum); } }

e=0 e<x.length 0 boolean(0< 101) 1<101 2< 101 3<101 4< 101 5<101 . 101<101

boolean test TRUE TRUE TRUE TRUE TRUE TRUE FALSE

sum=sum + e sum = 0 e e++ e 0 +0 0 0 1 1 0+1 1 1 1 2 1+2 3 2 1 3 3+3 6 3 1 4 6+4 10 4 1 5 10+5 15 5 1 6

You might also like