What does the following variable declaration in C mean, assuming it occurs within a function called my_function() ?
static int x = 0 ;
x retains its value between calls to my_function() |
||
x is a constant and cannot be changed within that function |
||
x is a global variable and can be accessed from other functions directly |
||
Syntax error, this is not a valid C statement. |
What does the following variable declaration in C mean, assuming it occurs within a function called my_function() ?
static int x = 0 ;
x retains its value between calls to my_function()-(ANSWER) |
||
x is a constant and cannot be changed within that function |
||
x is a global variable and can be accessed from other functions directly |
||
Syntax error, this is not a valid C statement. |
Option 1 is correct answer because x retains its value between calls to my_function().
Option 2 is the not the correct answer because x can be changed within a function.
Option 3 is not the correct answer because variables declared within a function as static variables have local scope and belong only to that block or function.
Option 4 is not the correct answer because it is not a syntax error and is a valid C statement.
Get Answers For Free
Most questions answered within 1 hours.