Question 11
What is the effect of declaring a function parameter as 'register int count' in C?
Detailed Solution
The 'register' keyword can be applied to function parameters as a compiler hint for register allocation.
What is the effect of declaring a function parameter as 'register int count' in C?
The 'register' keyword can be applied to function parameters as a compiler hint for register allocation.
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 = 13;' 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 = 14;
int main(void) {
int x = 24;
{
int x = 34;
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 = 15; 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.