1 vote
1 vote
Which of the following is TRUE?
A Scope of static variable is within the body of function where it is declared.

B Same variable can be declared multiple times within the same function only if it is extern storage class.

C Malloc always returns base address of block of memory allocated.

D None of the above

This is a multiple select question
in Programming in C
164 views

1 Answer

1 vote
1 vote

Correct Answer is A & C 

A. "Scope of static variable is within the body of the function where it is declared."

  • This statement is TRUE. The scope of a static variable is limited to the function or block in which it is declared.

B. "Same variable can be declared multiple times within the same function only if it is extern storage class."

  • This statement is FALSE. Regardless of the storage class (including extern), redeclaring the same variable within the same function would result in a compilation error. Redeclaring a variable within the same scope is not allowed in C.

C. "Malloc always returns the base address of the block of memory allocated."

  • This statement is TRUE. The malloc function in C returns a pointer to the base address of the dynamically allocated memory block..

Therefore, the TRUE statements are A and C.

Related questions