The correct statement about C structure is
1)Structure elements can be initialized at the time of declaration.
2)Structure members can not be initialized at the time of declaration
3)Only integer members of structure can be initialized at the time of declaration
4)None of the above
Answers
Answer:
3)Only integer members of structure can be initialized at the time of declaration
Members of structure at the time of its declaration can not be initialized . Thus, the '2' option is correct.
C structure:
No memory is allocated at the time when a datatype is declared. The memory allocation is done only after variables are created.
When we create a structure in c then the compiler get informed about it existence but no memory is allocated. In normal scenarios when we initialize any variable that depends on the place where we declared variable and the compiler allocate memory for that variable. If we initialized the structure member at the time of it's declaration then the program will show the compilation error.
Thus, initializing the members of structure in C at the time of it's declaration is not a good practice as a member without the memory cannot be of any use to the program and in C it is not a valid step.