C Questions and Answers Part-26

1. Register storage class can be specified to global variables.
a) true
b) false
c) Depends on the compiler
d) Depends on the standard

Answer: b

2. Which among the following is wrong for “register int a;”?
a) Compiler generally ignores the request
b) You cannot take the address of this variable
c) Access time to a is critical
d) None of the mentioned

Answer: d

3. What will be the output of the following C code?
#include < stdio.h >
void main()
{
register int x = 5;
m();
printf("x is %d", x);
}
void m()
{
x++;
}
a) 6
b) 5
c) Junk value
d) Compile time error

Answer: d

4. What is the scope of an automatic variable?
a) Within the block it appears
b) Within the blocks of the block it appears
c) Until the end of program
d) Within the block it appears & Within the blocks of the block it appears

Answer: d

5. Automatic variables are allocated space in the form of a __________
a) stack
b) queue
c) priority queue
d) random

Answer: a

6. Which of the following is a storage specifier?
a) enum
b) union
c) auto
d) volatile

Answer: c

7. If storage class is not specified for a local variable, then the default class will be auto.
a) true
b) false
c) Depends on the standard
d) None of the mentioned

Answer: a

8. What will be the output of the following C code?
#include < stdio.h >
void foo(auto int i);
int main()
{
foo(10);
}
void foo(auto int i)
{
printf("%d\n", i );
}
a) 10
b) Compile time error
c) Depends on the standard
d) 11

Answer: b

9. Automatic variables are stored in ________
a) stack
b) data segment
c) register
d) heap

Answer: a

10. What linkage does automatic variables have?
a) Internal linkage
b) External linkage
c) No linkage
d) None of the mentioned

Answer: c