QUIZ ON : C LANGUAGE - STORAGE CLASSES

STORAGE CLASSES

00:00:00

Automatic variables are initialized to

Option A. Zero
Option B. Junk value
Option C. Nothing
Option D. Both Zero & Junk value
True Answer B

Explanation :

Automatic variables are initialized to

Question No# : 01 out of 20



Which among the following is the correct syntax to declare a static variable register?

Option A. static register a;
Option B. register static a;
Option C. Both static register a; and register static a;
Option D. We cannot use static and register together
True Answer D

Explanation :

Which among the following is the correct syntax to declare a static variable register?

Question No# : 02 out of 20



Automatic variables are allocated memory in

Option A. heap
Option B. Data segment
Option C. Code segment
Option D. stack
True Answer D

Explanation :

Automatic variables are allocated memory in

Question No# : 03 out of 20



What is the output of the following code?

main()
{
static int num=8;
printf(“%d ”,num=num-2);
if(num!=0) main();
}

Option A. 8 6 4 2
Option B. Infinite output
Option C. 6 4 2 0
Option D. Invalid because main function can’t call itself.
True Answer C

Explanation :

What is the output of the following code?

main()
{
static int num=8;
printf(“%d ”,num=num-2);
if(num!=0) main();
}

Question No# : 04 out of 20



Which of the following is a storage specifier?

Option A. enum
Option B. union
Option C. auto
Option D. volatile
True Answer C

Explanation :

Which of the following is a storage specifier?

Question No# : 05 out of 20



The default storage class of a ‘C’ variable is

Option A. auto
Option B. static
Option C. extern
Option D. register
True Answer A

Explanation :
The auto storage class is the default storage class for all local variables. The example above defines two variables with in the same storage class. 'auto' can only be used within functions, i.e., local variables.

The default storage class of a ‘C’ variable is

Question No# : 06 out of 20

What is the scope of an automatic variable?

Option A. Exist only within that scope in which it is declared
Option B. Cease to exist after the block is exited
Option C. Exist only within that scope in which it is declared & exist after the block is exited
Option D. All of the mentioned
True Answer C

Explanation :

What is the scope of an automatic variable?

Question No# : 07 out of 20



Which of the following is not a proper storage class in ‘C’?

Option A. auto
Option B. dec
Option C. static
Option D. extern
True Answer B

Explanation :

Which of the following is not a proper storage class in ‘C’?

Question No# : 08 out of 20

What will be the output of the following code segment?

void fn() {
static int i = 10;
printf("%d ", ++i);
}
main() {
fn();
fn();
}

Option A. 10 10
Option B. 11 11
Option C. 11 12
Option D. 12 12
True Answer C

Explanation :

What will be the output of the following code segment?

void fn() {
static int i = 10;
printf("%d ", ++i);
}
main() {
fn();
fn();
}

Question No# : 09 out of 20



static storage class is used to make a variable global.

Option A. TRUE
Option B. FALSE
Option C.
Option D.
True Answer A

Explanation :

static storage class is used to make a variable global.

Question No# : 10 out of 20

Which of the following is not a proper storage class in C?

Option A. auto
Option B. dec
Option C. static
Option D. extern
True Answer B

Explanation :

Which of the following is not a proper storage class in C?

Question No# : 11 out of 20

The default initial value of a static int variable is zero.

Option A. TRUE
Option B. FALSE
Option C.
Option D.
True Answer A

Explanation :

The default initial value of a static int variable is zero.

Question No# : 12 out of 20

What is the scope of an external variable?

Option A. Whole source file in which it is defined
Option B. From the point of declaration to the end of the file in which it is defined
Option C. Any source file in a program
Option D. From the point of declaration to the end of the file being compiled
True Answer D

Explanation :

What is the scope of an external variable?

Question No# : 13 out of 20



Which data type can be stored in register?

Option A. int
Option B. long
Option C. float
Option D. All of the mentioned
True Answer D

Explanation :

Which data type can be stored in register?

Question No# : 14 out of 20



If storage class is not specified for a local variable, then the default class will be auto.

Option A. True
Option B. False
Option C. Depends on the standard
Option D. None of the mentioned
True Answer A

Explanation :

If storage class is not specified for a local variable, then the default class will be auto.

Question No# : 15 out of 20



If no storage class is mentioned for a variable defined in a function then it is by default auto.

Option A. TRUE
Option B. FALSE
Option C.
Option D.
True Answer A

Explanation :

If no storage class is mentioned for a variable defined in a function then it is by default auto.

Question No# : 16 out of 20

Global variables are

Option A. Internal
Option B. External
Option C. Both Internal and External
Option D. None of the mentioned
True Answer B

Explanation :

Global variables are

Question No# : 17 out of 20



What is the scope of an automatic variable?

Option A. Within the block it appears
Option B. Within the blocks of the block it appears
Option C. Until the end of program
Option D. Within the block it appears & Within the blocks of the block it appears
True Answer D

Explanation :

What is the scope of an automatic variable?

Question No# : 18 out of 20



Identify the storage class with which & operator cannot be used.

Option A. register
Option B. static
Option C. extern
Option D. auto
True Answer A

Explanation :
The register storage class is used to define local variables that should be stored in a register instead of RAM. This means that the variable has a maximum size equal to the register size (usually one word) and can't have the unary '&' operator applied to it (as it does not have a memory location).

Identify the storage class with which & operator cannot be used.

Question No# : 19 out of 20

The machine registers are sometimes called

Option A. local variables
Option B. global variables
Option C. accumulators
Option D. static variables
True Answer A

Explanation :

The machine registers are sometimes called

Question No# : 20 out of 20