Question 66
Which memory segment stores uninitialized global and static variables in C?
Detailed Solution
Uninitialized static and global variables are stored in the BSS (Block Started by Symbol) segment and zero-filled before execution.
Which memory segment stores uninitialized global and static variables in C?
Uninitialized static and global variables are stored in the BSS (Block Started by Symbol) segment and zero-filled before execution.
What is the scope and linkage of a top-level global variable declared as 'static int var = 67;' in a C source file?
The 'static' specifier at file scope restricts visibility to internal linkage, making the variable accessible only within the declaring translation unit.
What is the output of the following C code?
#include <stdio.h>
int x = 68;
int main(void) {
int x = 78;
{
int x = 88;
printf("%d ", x);
}
printf("%d", x);
return 0;
}Inner block scope declarations shadow outer scope declarations of the same identifier name.
Consider a function returning a value: 'int calc(int a) { static int s = 69; s += a; return s; }'. What is returned by calling calc(5) twice consecutively?
Static local variable 's' retains its updated value across consecutive function calls.
What does the declaration 'extern int arr[70];' inside a function indicate?
'extern' provides a reference to a global symbol defined elsewhere; it does not allocate memory.