Vidyalelo
C Programming · Q37

Arrays and Strings

Programming · C Programming · question 37

Q37

Size of the array need not be specified, when

A.
Initialization is a part of definition
Answer
B.
It is a declaratrion
C.
It is a formal parameter
D.
All of these

Answer: Option A

Solution

Answer: Option A
Solution:
In C programming, the size of the array does not need to be specified when initialization is a part of definition.

Initialization during Definition:
When an array is defined and initialized at the same time, the size of the array can be omitted. The size is automatically determined by the number of elements provided in the initialization. For example:
int arr[] = {1, 2, 3, 4, 5}; // Size is determined by the number of elements

Declaration:
When declaring an array without initializing it, the size must be specified if the array is not initialized. For example:
int arr[5]; // Size must be specified

Formal Parameter:
In function prototypes or definitions where an array is used as a formal parameter, the size does not need to be specified. For example:
void function(int arr[]); // Size not required

All of These:
This option is incorrect because the size must be specified in cases other than initialization during definition.

Therefore, the correct answer is Option A: Initialization is a part of definition.