The answer to your fist question is "no", only the explicitly initialised variable will be assigned. The others may have any value, (including zero).
To answer your second (more interesting) question (which perhaps deserved a separate question):
The term "unitialised" simply means that no value is explicitly assigned at instantiation; the value is whatever happens to be in the associated memory location at that time. Some environments fill the stack with zero at the start of execution so in trivial examples zero is likely. It will not be true all the time however as the stack is churned over during execution, and contains different values left over from previously executed code.
For example in the following, it is likely that a
in fn()
will not be zero for every call (or possibly any call) and will change between calls:
void fn()
{
static int i = 1 ;
volatile int a ;
printf( "Call %d: a = %d\n", i, a ) ;
i++ ;
a = i ;
}
int main()
{
for( int i = 0; i < 10; i++ )
{
fn() ;
}
}
In my test (at ideone.com) it output the following:
Call 1: a = 134513970
Call 2: a = 2
Call 3: a = 3
Call 4: a = 4
Call 5: a = 5
Call 6: a = 6
Call 7: a = 7
Call 8: a = 8
Call 9: a = 9
Call 10: a = 10
As you can see in the second and subsequent calls it contains whatever was left at that location from the previous call because the same stack location is reused. A different calling pattern - for example insert a function call before or after fn()
will produce a different and less predictable result when that stack area is reused by other functions. For example when I modified the loop body as follows:
rand() ;
fn() ;
The result was:
Call 1: a = 1433091188
Call 2: a = 1433091188
Call 3: a = 1433091188
Call 4: a = 1433091188
Call 5: a = 1433091188
Call 6: a = 1433091188
Call 7: a = 1433091188
Call 8: a = 1433091188
Call 9: a = 1433091188
Call 10: a = 1433091188