Related Articles

Related Articles

C Quiz – 108 | Question 5
  • Difficulty Level : Easy
  • Last Updated : 17 Oct, 2015

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

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.

My Personal Notes arrow_drop_up
Recommended Articles
Page :