CHALLENGES


Solution

Output :- Prints 5 3 2 1 1 on separate line
REASON:

Solution

Output :- Loops
REASON: loops go round and round and when the condition becomes false it comes out

Solution

Output :- Arrays
REASON: Since it can store more items but of similar types only, it is homogeneous and hence arrays is the answer

Solution

Output :- Prints 5 3 2 1 1 on separate line
REASON: s=1 and j=10, when do loop starts execution is as follows:
s=2 => prints 10/2 = 5, j=9
s=3 => prints 9/3 = 3, j=8
s=4 => prints 8/4 = 2, j=7
s=5 => prints 7/5 = 1, j=6
s=6 => prints 6/6 = 1, j=5
Now here s<j is false loop stops

Solution

Output :- Prints 2 4 9 6 3 on separate line
REASON: The expression a[i] += ( a[i+1]++ ) – ( --a[i-1] ), with value of i=2, is evaluated as follows :
a[2] = a[2] + ( a[3]++ ) - ( --a[1])
a[2] = 8 + (5) - (4) = 9
And after this statement is executed values at index 3 and 1 also changes to 6 and 4 respectively.

Solution

Output :- Prints 1 2 3 4 5 6 7 8 9 10 on separate line
REASON: For every value of i, the s loop runs "i" times. Every time the "s" loop executes, value of m is getting initialized to 0. Hence it prints the last calculated sum in the "s" loop.

Solution

Output :-
10
11
REASON: The expression x++ < 10 => 10 < 10 and --y <= x => 11 <= 11 [ Here value of x becomes 11 due to post-increment operator in previous expression ] evaluates to false. It goes in next else if, here the expression --x % 2 == 0 => 10 % 2 == 0 is true hence statement 2 is executed and vaues of x and y are 10 and 11 respectively