Machine-translated by Google. Questions are authored in English.
Top

Discussion

Predict the output of below code: 

#include <stdio.h>
    int main()
    {
        int ary[2][3][4], j = 20;
        ary[0][0] = &j;
        printf("%d\n", *ary[0][0]);
    }

 

  • A.Junk Value
  • B.No output
  • C.Compile time Error
  • D.Address of j

Answer: C

Correct answer: Compile time Error

ary[0][0] has type int[4] - a whole row of four ints, not a single element. An array is not a modifiable lvalue, so it cannot be assigned to, and the type on the right, int *, does not match in any case. The compiler rejects the assignment; ary[0][0][0] = j; would be the sensible statement.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.