C Quiz – 108 | Question 5

In a C file (say sourcefile1.c), an array is defined as follows. Here, we don’t need to mention arrary arr size explicitly in [] because the size would be determined by the number of elements used in the initialization.

filter_none

edit
close

play_arrow

link
brightness_4
code

int arr[] = {1,2,3,4,5};

chevron_right


In another C file (say sourcefile2.c), the same array is declared for usage as follows:

filter_none

edit
close

play_arrow

link
brightness_4
code

extern int arr[];

chevron_right


In sourcefile2.c, we can use sizeof() on arr to find out the actual size of arr.
(A) TRUE
(B) FALSE


Answer: (B)

Explanation: First thing first, sizeof() operator works at compile time. So usage of sizeof on arr in sourcefile2.c won’t work because arr in sourcefile2.c is an incomplete type. Please note that arr in sourcefile1.c is a complete type because size of array got determined at compile time due to initialization.

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.