Skip to content
Related Articles
Open in App
Not now

Related Articles

C Quiz – 108 | Question 5

Improve Article
Save Article
  • Difficulty Level : Easy
  • Last Updated : 31 May, 2021
Improve Article
Save Article

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

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

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

extern int arr[];

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

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
Related Articles

Start Your Coding Journey Now!