C Programming Questions and Answers – Automatic Variables – 2

«
»
Sanfoundry’s 1000+ Interview Questions & Answers on C helps anyone preparing for Samsung and other companies C interviews. One should practice these 1000+ interview questions and answers continuously for 2-3 months to clear Samsung interviews on C Programming language.

Here is a listing of online C test questions on “Automatic Variables” along with answers, explanations and/or solutions:

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.
advertisement

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.

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

Answer: d
Explanation: None.
advertisement
advertisement

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

  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.
advertisement

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.

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.
advertisement

Sanfoundry Global Education & Learning Series – C Programming Language.

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!

advertisement
advertisement

Leave a Comment

Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He is Linux Kernel Developer & SAN Architect and is passionate about competency developments in these areas. He lives in Bangalore and delivers focused training sessions to IT professionals in Linux Kernel, Linux Debugging, Linux Device Drivers, Linux Networking, Linux Storage, Advanced C Programming, SAN Storage Technologies, SCSI Internals & Storage Protocols such as iSCSI & Fiber Channel. Stay connected with him @ LinkedIn | Youtube | Instagram | Facebook | Twitter