Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

GATE | GATE CS 2020 | Question 32

  • Difficulty Level : Medium
  • Last Updated : 11 Aug, 2021

Consider the following C program.

Attention reader! Don’t stop learning now.  Practice GATE exam well before the actual exam with the subject-wise and overall quizzes available in GATE Test Series Course.

Learn all GATE CS concepts with Free Live Classes on our youtube channel.




#include <stdio.h> 
int main ()  { 
    int  a[4][5] = {{1, 2, 3, 4, 5}, 
                    {6, 7, 8, 9, 10}, 
                    {11, 12, 13, 14, 15}, 
                    {16, 17, 18, 19, 20}}; 
    printf("%d\n", *(*(a+**a+2)+3)); 
    return(0); 
}  

The output of the program is _______ .

Note – This question was Numerical Type.
(A) 18
(B) 19
(C) 20
(D) 14


Answer: (B)

Explanation: Given a[4][5] is 2D array. Let starting address (or base address) of given array is 1000.



Therefore,

= *(*(a+**a+2)+3))
= *(*(1000+**1000+2)+3))
= *(*(1000+3)+3))   {given element **1002 = 3}
= *(*(1003)+3))
= *((1003)+3)    {4th row selected in given matrix}
= *((1003)+3)     {address of 4th element in 4th row}
= a[3][3]
= 19            {element selected a[3][3] = 19} 




#include <stdio.h> 
int main ()  { 
    int  a[4][5] = {{1, 2, 3, 4, 5}, 
                    {6, 7, 8, 9, 10}, 
                    {11, 12, 13, 14, 15}, 
                    {16, 17, 18, 19, 20}}; 
    printf("%d\n", *(*(a+**a+2)+3)); 
    return(0); 
}  

Option (B) is correct.



Quiz of this Question




My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!