Multiple choice

How does variable definition differ from variable declaration?

  1. Definition allocates storage for a variable, but declaration only informs the compiler as to the variable's type.

  2. Declaration allocates storage for a variable, but definition only informs the compiler as to the variable's type.

  3. Variables may be defined many times, but may be declared only once.

  4. Variable definition must precede variable declaration.

  5. There is no difference in C between variable declaration and variable definition.

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

A variable definition causes memory storage to be allocated for that variable, whereas a variable declaration simply introduces the variable identifier and its type to the compiler without reserving storage.