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

1-C-Programming - Storage-Classes-Download PDF

The document contains 5 multiple choice questions about storage classes in C programming. The questions cover topics like scope of automatic and static variables, output of code segments using static variables, valid storage classes in C, and behavior of static storage variables across function calls.

Uploaded by

NAGARAJAN S
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)
72 views3 pages

1-C-Programming - Storage-Classes-Download PDF

The document contains 5 multiple choice questions about storage classes in C programming. The questions cover topics like scope of automatic and static variables, output of code segments using static variables, valid storage classes in C, and behavior of static storage variables across function calls.

Uploaded by

NAGARAJAN S
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

gkseries.

com
http://www.gkseries.com/computer-engineering/c-programming/storage-classes/c-programming-quiz-questions-and-answers-1

C quiz questions with answers - Storage classes MCQs

1.

Regarding the scope of the variables identify the incorrect statement:

[A] Automatic variables are automatically initialized to 0

[B] Static variables are automatically initialized to 0

[C] The address of a register variable is not accessible

[D] Static variables cannot be initialized with any expression

Answer & Explanation

Answer: Option [A]

By default Automatic variables are initialized to Garbage value.

2.

What will be the output of the following code segment?

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

[A] 10 10

[B] 11 11

[C] 11 12

[D] 12 12

Answer & Explanation

Answer: Option [C]


3.

Which of the following is not a proper


storage class in 'C'?

[A] auto

[B] dec

[C] static

[D] extern

Answer & Explanation

Answer: Option [B]

The storage classes in C are auto,


extern, static and global. dec is not a
storage class.

4.

What is the output of the following code?

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

[A] 8 6 4 2

[B] Infinite output

[C] 6 4 2 0

[D] invalid because main function cannot call itself

Answer & Explanation

Answer: Option [C]


5.

Value of static storage variable

[A] changes during different function


calls

[B] persists between different function


calls

[C] increases during different function


calls

[D] decreases during different function


calls

Answer & Explanation

Answer: Option [B]

You might also like