C Programming Questions and Answers – Automatic Variables – 2

This set of C Multiple Choice Questions & Answers (MCQs) focuses on “Automatic Variables – 2”.

Pre-requisite for this C MCQ set: Advanced C Programming Video Tutorial.

1. Automatic variables are _________
a) Declared within the scope of a block, usually a function
b) Declared outside all functions
c) Declared with the auto keyword
d) Declared within the keyword extern
View Answer

Answer: a
Explanation: None.

2. What is the scope of an automatic variable?
a) Exist only within that scope in which it is declared
b) Cease to exist after the block is exited
c) Exist only within that scope in which it is declared & exist after the block is exited
d) All of the mentioned
View Answer

Answer: c
Explanation: None.
advertisement
advertisement

3. Automatic variables are allocated memory in ___________
a) heap
b) Data segment
c) Code segment
d) stack
View Answer

Answer: d
Explanation: None.

4. What will be the x in the following C code?

Sanfoundry Certification Contest of the Month is Live. 100+ Subjects. Participate Now!
  1.     #include <stdio.h>
  2.     void main()
  3.     {
  4.         int x;
  5.     }

a) automatic variable
b) static variable
c) register variable
d) global variable
View Answer

Answer: a
Explanation: None.
advertisement

5. Automatic variables are initialized to ___________
a) Zero
b) Junk value
c) Nothing
d) Both Zero & Junk value
View Answer

Answer: b
Explanation: None.

6. Which of the following storage class supports char data type?
a) register
b) static
c) auto
d) all of the mentioned
View Answer

Answer: d
Explanation: None.
advertisement

7. A local variable declaration with no storage class specified is by default _________
a) auto
b) extern
c) static
d) register
View Answer

Answer: a
Explanation: None.

Sanfoundry Global Education & Learning Series – C Programming Language.

To practice all areas of C language, here is complete set of 1000+ Multiple Choice Questions and Answers.

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.