QUIZ ON : C LANGUAGE - STORAGE CLASSES

STORAGE CLASSES

00:00:00

What is the output of this C code?

#include <stdio.h>

void main()

{

static int x;

if (x++ < 2)

main();

}

Option A. Infinite calls to main
Option B. Run time error
Option C. Varies
Option D. main is called twice
True Answer D

Explanation :

What is the output of this C code?

#include <stdio.h>

void main()

{

static int x;

if (x++ < 2)

main();

}

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



Identify the storage class with which &amp; 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&#39;t have the unary &#39;&amp;&#39; operator applied to it (as it does not have a memory location).

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

Question No# : 03 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# : 04 out of 20

Register variable are active

Option A. outside the function
Option B. throughout the program
Option C. only in the function where it is defined
Option D. surrounding of that function
True Answer C

Explanation :

Register variable are active

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



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



The lifetime of a static variable is the duration of your program&#39;s execution.

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

Explanation :

The lifetime of a static variable is the duration of your program&#39;s execution.

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

A local variable declaration with no storage class specified is by default

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

Explanation :

A local variable declaration with no storage class specified is by default

Question No# : 14 out of 20



What is the output of the following code segment?

void fn() {
int a = 10;
static int b = 20;
printf("a = %d b = %d ", ++a, ++b);
}
int main() {
fn();
fn();
return 0;
}

Option A. a = 11 b = 21 a = 11 b = 21
Option B. a = 11 b = 21 a = 12 b = 21
Option C. a = 11 b = 21 a = 11 b = 22
Option D. a = 11 b = 21 a = 12 b = 22
True Answer C

Explanation :

What is the output of the following code segment?

void fn() {
int a = 10;
static int b = 20;
printf("a = %d b = %d ", ++a, ++b);
}
int main() {
fn();
fn();
return 0;
}

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

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



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



‘auto’ keyword is used to declare a local variable.

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

Explanation :

‘auto’ keyword is used to declare a local variable.

Question No# : 19 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# : 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