Storage Classes and Type Qualifiers in C (original) (raw)
Which of the following is NOT a storage class in C?
What does the extern storage class specify?
- Global variable with static scope
- Declaration of a variable defined elsewhere
- Immediate memory allocation
What is the default storage class for local variables in C?
What is the key feature of a static variable inside a function?
- It is shared across all functions
- It resets every time the function is called
- It retains its value between function calls
- It is allocated in the CPU register
Which qualifier tells the compiler not to optimize access to a variable?
What will be the output of the following code?
C `
#include <stdio.h>
void demo() { static int count = 0; count++; printf("%d ", count); }
int main() { demo(); demo(); demo(); return 0; }
`
What will be the output of the following code?
C `
#include <stdio.h>
int x = 10;
void print() { extern int x; printf("%d\n", x); }
int main() { print(); return 0; }
`
What is the output of this code?
C `
#include <stdio.h>
int main() { register int x = 5; printf("%d\n", x); return 0; }
`
What will happen when this code runs?
C `
#include <stdio.h>
int main() { const int a = 5; int *p = &a; *p = 10; printf("%d\n", a); return 0; }
`
Which variable will retain its value across multiple calls?
C `
#include <stdio.h>
void fun() { auto int x = 0; x++; printf("%d ", x); }
int main() { fun(); fun(); return 0; }
`
There are 18 questions to complete.
Take a part in the ongoing discussion