C Quiz – 106 | Question 5

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

filter_none

edit
close

play_arrow

link
brightness_4
code

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

chevron_right


(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



My Personal Notes arrow_drop_up


Article Tags :
Practice Tags :


Be the First to upvote.


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