C variable and control Flow questions and Answers
1. What is the difference between declaring a variable and defining a variable?
Declaration of a variable in C hints the compiler about the type and size of the variable in compile time. Similarly, declaration of a function hints about type and size of function parameters. No space is reserved in memory for any variable in case of declaration.
Example: int a;
Here variable 'a' is declared of data type 'int' Defining a variable means declaring it and also allocating space to hold it. We can say "Definition = Declaration + Space reservation".
Example: int a = 10;
Here variable "a" is described as an int to the compiler and memory is allocated to hold value 10
.
Read More »
Tags:
c question,
c variables