What is the difference between variable initialization and variable definition? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

What is the difference between variable initialization and variable definition?

30th Nov 2019, 8:54 AM
Dany Fentom
Dany Fentom - avatar
1 Answer
+ 7
Definition means where you define the variable that you will be using in your code For example : int a; //Here you defined the variable a, it means it will reserve a empty memory space for future values. Initialization means assigning a value to variable. For example : a = 10; //Here we assigned value of 10 to the variable be already defined -> note : you can also do definition and initialization at a time For example : int a = 10;
30th Nov 2019, 8:59 AM
Raj Chhatrala
Raj Chhatrala - avatar