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.
Sanfoundry Certification Contest of the Month is Live. 100+ Subjects. Participate Now!
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.

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

advertisement
advertisement

Leave a Comment

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 & technical discussions at Telegram SanfoundryClasses.