Skip to content
Related Articles

Related Articles

Improve Article
C Quiz – 106 | Question 5
  • Difficulty Level : Hard
  • Last Updated : 12 Oct, 2015

For the following “typedef” in C, pick the best statement




typedef int INT, *INTPTR, ONEDARR[10], TWODARR[10][10];

(A) It will cause compile error because typedef is being used to define multiple aliases of incompatible types in the same statement.
(B) “INT x” would define x of type int. Remaining part of the statement would be ignored.
(C) “INT x” would define x of type int and “INTPTR y” would define pointer y of type int *. Remaining part of the statement would be ignored.
(D) “INT x” would define x of type int. “INTPTR y” would define pointer y of type int *. ONEDARR is an array of 10 int. TWODARR is a 2D array of 10 by 10 int.

(E) “INT x” would define x of type int. “INTPTR *y” would define pointer y of type int **. “ONEDARR z” would define z as array of 10 int. “TWODARR t” would define t as array of 10 by 10 int.


Answer: (E)

Explanation: Here, INT is alias of int. INTPTR is alias of int *. That’s why INTPTR * would be alias of int **. Similarly, ONEDARR is defining the alias not array itself. ONEDARR would be alias to int [10]. That’s why “ONEDARR z” would define array z of int [10]. Similarly, TWODARR would be alias to int [10][10]. Hence “TWODARR t” would define array t of int [10][10]. We can see that typedef can be used to create alias or synonym of other types.

Quiz of this Question

Want to learn from the best curated videos and practice problems, check out the C Foundation Course for Basic to Advanced C.
My Personal Notes arrow_drop_up
Recommended Articles
Page :