QUIZ ON : C LANGUAGE - STORAGE CLASSES

STORAGE CLASSES

00:00:00

Which of the following operation is not possible in a register variable?

Option A. Reading the value into a register variable
Option B. Copy the value from a memory variable
Option C. Global declaration of register variable
Option D. All of the mentioned
True Answer D

Explanation :

Which of the following operation is not possible in a register variable?

Question No# : 01 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# : 02 out of 20



Which of the following statement is false?

Option A. Constant variables need not be defined as they are declared and can be defined later
Option B. Global constant variables are initialized to zero
Option C. const keyword is used to define constant values
Option D. You cannot reassign a value to a constant variable
True Answer A

Explanation :
Since the constant variable has to be declared and defined at the same time, not doing it results in an error.

Which of the following statement is false?

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



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# : 05 out of 20



Automatic variables are allocated space in the form of a

Option A. stack
Option B. queue
Option C. priority queue
Option D. random
True Answer A

Explanation :

Automatic variables are allocated space in the form of a

Question No# : 06 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# : 07 out of 20



Which of the following storage class supports char data type?

Option A. register
Option B. static
Option C. auto
Option D. all of the mentioned
True Answer D

Explanation :

Which of the following storage class supports char data type?

Question No# : 08 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# : 09 out of 20



Automatic variables are stored in

Option A. stack
Option B. data segment
Option C. register
Option D. heap
True Answer A

Explanation :

Automatic variables are stored in

Question No# : 10 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# : 11 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# : 12 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# : 13 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# : 14 out of 20



Automatic variables are

Option A. Declared within the scope of a block, usually a function
Option B. Declared outside all functions
Option C. Declared with the auto keyword
Option D. Declared within the keyword extern
True Answer A

Explanation :

Automatic variables are

Question No# : 15 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# : 16 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# : 17 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# : 18 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# : 19 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# : 20 out of 20




CCC Online Test 2021 CCC Practice Test Hindi Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Best Java Training Institute in Prayagraj (Allahabad) Best Python Training Institute in Prayagraj (Allahabad) O Level NIELIT Study material and Quiz Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Sarkari Naukari Notification Best Website and Software Company in Allahabad Website development Company in Allahabad