Consider the following C code:
int A[100][100]; int main() { for(int i=1; i < 100 ; i++) for(int j=1; j < 100;j++) A[i][j] = (i/j)*(j/i); return 0; }
What will be the sum of the all the elements of double dimensional array A after implementing the above function ?
(A) 100
(B) 99
(C) (100*99)/2
(D) 0
Answer: (B)
Explanation: Since array is global A[0][j] = A[i][0] = 0.
Final value after adding all the values of this array will be 99 . Only diagonal element will be having 1’s except A[0][0] and rest all are zeroes as integer division (i/j) when j > i will be 0.
Quiz of this Question