Open In App

C Quiz – 108 | Question 5

Like Article
Like
Save
Share
Report

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.
(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


Last Updated : 31 May, 2021
Like Article
Save Article
Share your thoughts in the comments
Similar Reads