What is Difference Between Declaring a Variable and Defining a Variables

28 Dec 2022 Balmiki Kumar 0 C Programming

What is the difference between declaring a variable and defining a variable?


Declaration of variables:

⇒Deceleration of a variable means only mentioning the data type or variable name not assigning any value for it.

⇒ the compiler knows about the type and size of the variable.No value is assign in  memory .

Example:

int a;

here variable 'a' is declared of data type 'int'


Defining a variable

⇒Defining a variable means declaring as well as assigning the value for it is called deceleration of variable.

⇒Defining a variable means declaring it also allocating space to hold it.

we can say :
"Definination=Decaration+Space reservation".

Example:

​​​​​​​int a=10;

 

conclusion:

here int is a variable type 

a is the variable name 

10 is assigning on integer variable a.

Note:-Here variable "a" is described as an into the compiler and memory is allocated to hold value 10.

 

BY: Balmiki Kumar

Related Blogs

Post Comments.

Login to Post a Comment

No comments yet, Be the first to comment.