Answer:
Condition one - 1 time
Condition two - 2 times
Explanation:
Given
The above code segment
Required
Determine the number of times each print statement is executed
For condition one:
The if condition required to print the statement is: <em>if (arr[row][col] >= arr[row][col - 1]) </em>
<em />
For the given data array, this condition is true only once, when
and
i.e.
<em>if(arr[row][col] >= arr[row][col - 1]) </em>
=> <em>arr[1][2] >= arr[1][2 - 1]</em>
=> <em>arr[1][2] >= arr[1][1]</em>
<em>=> 5 >= 3 ---- True</em>
<em />
The statement is false for other elements of the array
Hence, Condition one is printed once
<em />
<em />
For condition two:
The if condition required to print the statement is: <em>if (arr[row][col] % 2 == 0) </em>
<em />
The condition checks if the array element is divisible by 2.
For the given data array, this condition is true only two times, when
and
and
i.e.
<em>if (arr[row][col] % 2 == 0) </em>
<em>When </em> and
<em>=>arr[0][1] % 2 == 0</em>
<em>=>2 % 2 == 0 --- True</em>
<em />
<em>When </em> and
<em>=>arr[1][0] % 2 == 0</em>
<em>=> 4 % 2 == 0 --- True</em>
<em />
<em />
The statement is false for other elements of the array
Hence, Condition two is printed twice