I am confusion on initialization of variable in c. C variables are names used for storing a data value to locations in memory
Declaration of variable in c can be done using following syntax:
data_type variable_name;
Example: int i; where i is variable name. this is example of variable declaration with single name
or
data_type variable1, variable2,…,variablen;
Example: int i, j,k; this is example of variable declaration with multiple name
assign value to variable name
example: int i = 6;
Than initialization of variable look like this
syntax: for(initialization; test; increment)
Example: for(i=0; <5; i++);
Declaration and initialization
int i;
for(i=0;i<5;i++);
compiler set i=0 and then increment by 1
program output 0,1,2,3,4
can we initialization like this? I think no
int i=2;
for(i=0;i<5;i++);
this program show output 0,1,2,3,4. why does it not show 2,3,4 while int i=2;
what happens to declared but uninitialized variable. does it have a value?