# Ravi and Rupali are asked to write a program to sum the rows of 2X2 matrices stored in the array A..?

Answer : B. Code b will execute faster than a

Ravi and Rupali are asked to write a program to sum the rows of 2X2 matrices stored in the array A.
Ravi writes the following code (Code A):

``` for n = 0 to 1
sumRow1[n] = A[n][1] + A[n][2]
end```

Rupali writes the following code (Code B):

```sumRow1[0] = A[0][1] + A[0][2]
sumRow1[1] = A[1][1] + A[1][2]```

Comment upon these codes (Assume no loop unrolling done by compiler) ?

A. Code a will execute faster than b.

B. Code b will execute faster than a.

C. Code a is logically incorrect.

D. Code b is logically incorrect

## Explanation:

• Both codes are taking two steps of operation, so same complexity.
• But if we consider the overhead of looping (as it takes time to increment counter) then code b will be faster.

## Integer a =40, b =35, c=20, d =10 Comment about the output of the following two statements Print a*b/c-d Print a*b/(c-d) ?

Answer : A . Differ by 80