C Programming Questions and Answers – Automatic Variables – 1

«
»

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

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

advertisement

1. What is the scope of an automatic variable?
a) Within the block it appears
b) Within the blocks of the block it appears
c) Until the end of program
d) Within the block it appears & Within the blocks of the block it appears
View Answer

Answer: d
Explanation: None.

2. Automatic variables are allocated space in the form of a __________
a) stack
b) queue
c) priority queue
d) random
View Answer

Answer: a
Explanation: None.
advertisement
advertisement

3. Which of the following is a storage specifier?
a) enum
b) union
c) auto
d) volatile
View Answer

Answer: c
Explanation: None.

4. If storage class is not specified for a local variable, then the default class will be auto.
a) True
b) False
c) Depends on the standard
d) None of the mentioned
View Answer

Answer: a
Explanation: None.
advertisement

5. What will be the output of the following C code?

  1.     #include <stdio.h>
  2.     void foo(auto int i);
  3.     int main()
  4.     {
  5.         foo(10);
  6.     }
  7.     void foo(auto int i)
  8.     {
  9.         printf("%d\n", i );
  10.     }

a) 10
b) Compile time error
c) Depends on the standard
d) None of the mentioned
View Answer

Answer: b
Explanation: None.
advertisement

6. Automatic variables are stored in ________
a) stack
b) data segment
c) register
d) heap
View Answer

Answer: a
Explanation: None.
advertisement

7. What linkage does automatic variables have?
a) Internal linkage
b) External linkage
c) No linkage
d) None of the mentioned
View Answer

Answer: c
Explanation: None.

8. What will be the output of the following C code?

  1.     #include <stdio.h>
  2.     int main()
  3.     {
  4.         auto i = 10;
  5.         const auto int *p = &i;
  6.         printf("%d\n", i);
  7.     }

a) 10
b) Compile time error
c) Depends on the standard
d) Depends on the compiler
View Answer

Answer: a
Explanation: None.

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

Check his free tutorial videos on Advanced C Programming. Join his Sanfoundry-Classes telegram channel for all videos and queries on Programming, Data-Structures, Kernel, Personality development and Mentoring.