0
How to initialize the variable?
I'm new here.
3 Réponses
+ 12
int a; //declare a veriable
a = 10; // initilize a veriable
+ 3
Initializing a variable means specifying an initial value to assign to it (i.e., before it is used at all). Notice that a variable that is not initialized does not have a defined value, hence it cannot be used until it is assigned such a value.
You need the assignment operator(=) which assigns a value to a variable.
x = 5;
0
You give an initial value of your variable.
There are two case:
1. You declare variable first and after it you give an initial value, as Sumit Programmer says
2. You declare variable and give initial value in one step
An example:
int a=10;