int int for k-- System out println System out println ________________

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
a. int y = 1;
int k;
for(k = 6; k >= 3; k--)
y = y + k;
System.out.println("y = " + y);
System.out.println("k = " + k);
__________________________________
Відповідь:
y = 7
k = 6
y = 6
k = 5
y = 5
k = 4
y = 4
k = 3
к-сть 4 рази виконувався цикл!
---------------------------------------------------------------------------------
b. int y = 6;
int k;
for(k = 1; k <= 6; k++)
y = y+k;
y = y * 10;
System.out.println("y = " + y);
System.out.println("k = " + k);
________________________________________
Відповідь:
c. int y = 2;
int k;
for(k = 7; k <= 2; k++)
y = y + k;
System.out.println("y = " + y);
System.out.println("k = " + k);
d. int y = 0;
int k = 4;
while (k > 1 ){
y = y + 1 / k;
k = k - 1;
}
System.out.println("y = " + y);
System.out.println("k = " + k);
e. int y = 0;
int k = 3;
do {
k = k * 2;
y = y + k;
}
while (k < 7);
System.out.println("y = " + y);
System.out.println("k = " + k);