Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

GATE | GATE MOCK 2017 | Question 25

  • Last Updated : 28 Jun, 2021

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

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!