GATE | GATE MOCK 2017 | Question 22

What will be the output produced by the following C code:

int main()
{
    int array[5][5];
    printf("%d",( (array == *array) && (*array == array[0]) ));
    return 0;    
}

(A) 1
(B) 0
(C) 2
(D) -1


Answer: (A)

Explanation:
Given is a 2d array array[5][5].
Suppose base address of array is 2000

array = 2000
*array = 2000

array[0] = 2000

So expression is something like 2000==2000 && 2000==2000 i.e. 1&&1 will return 1.



Quiz of this Question



My Personal Notes arrow_drop_up


Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.