[go: up one dir, main page]

0% found this document useful (0 votes)
66 views3 pages

Declaration of Storage Class in C

The document provides a quiz on storage class specifiers in programming, detailing the functions and characteristics of various specifiers such as 'register', 'auto', 'extern', and 'static'. It includes questions about variable storage, scope, lifespan, and default values. Each question is followed by the correct answer, enhancing understanding of how these storage classes operate within a program.

Uploaded by

Vijaya kumari
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
66 views3 pages

Declaration of Storage Class in C

The document provides a quiz on storage class specifiers in programming, detailing the functions and characteristics of various specifiers such as 'register', 'auto', 'extern', and 'static'. It includes questions about variable storage, scope, lifespan, and default values. Each question is followed by the correct answer, enhancing understanding of how these storage classes operate within a program.

Uploaded by

Vijaya kumari
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Declaration of Storage Class

1.​ Which storage class specifier tells the compiler to store the variable
in the CPU registers?​

○​ a) static
○​ b) extern
○​ c) register
○​ d) auto
○​ Answer: c) register
2.​ Variables declared inside a function without any storage class
specification are by default:​

○​ a) static
○​ b) extern
○​ c) register
○​ d) auto
○​ Answer: d) auto
3.​ Which storage class specifier makes a variable accessible across
multiple files?​

○​ a) static
○​ b) extern
○​ c) register
○​ d) auto
○​ Answer: b) extern
4.​ Which storage class specifier preserves the variable's value between
function calls?​

○​ a) static
○​ b) extern
○​ c) register
○​ d) auto
○​ Answer: a) static
5.​ What is the default initial value of a static variable?​

○​ a) Garbage value
○​ b) 1
○​ c) 0
○​ d) -1
○​ Answer: c) 0
6.​ Which storage class is not allowed for global variables?​

○​ a) static
○​ b) extern
○​ c) register
○​ d) All are allowed.
○​ Answer: c) register
7.​ The scope of a static variable declared inside a function is:​

○​ a) Global
○​ b) Within the function
○​ c) Within the block it is defined
○​ d) Across all files
○​ Answer: b) Within the function
8.​ The lifespan of an auto variable is:​

○​ a) Throughout the program


○​ b) Until the function returns
○​ c) Until the block it is defined ends
○​ d) Until the program terminates
○​ Answer: c) Until the block it is defined ends
9.​ Which storage class is used to declare a variable that is known to all
functions in a program file?​

○​ a) static
○​ b) extern
○​ c) register
○​ d) auto
○​ Answer: a) static (when declared outside of functions)
10.​ What is the scope of an extern variable?​

○​ a) Local to the function


○​ b) Global to the entire program
○​ c) Local to the file
○​ d) Global to the block
○​ Answer: b) Global to the entire program

You might also like