0

How to initialize the variable?

I'm new here.

14th Jul 2019, 4:53 PM
Purusharth Sachdeva
Purusharth Sachdeva - avatar
3 ответов
+ 12
int a; //declare a veriable a = 10; // initilize a veriable
14th Jul 2019, 5:03 PM
Sumit Programmer😎😎
Sumit Programmer😎😎 - avatar
+ 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;
14th Jul 2019, 5:32 PM
Muaz Ahmad
Muaz Ahmad - avatar
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;
14th Jul 2019, 5:29 PM
Lennie
Lennie - avatar