250+ TOP MCQs on Automatic Variables and Answers

C quiz on “Automatic Variable”. One shall practice these quizzes to improve their C programming skills needed for various interviews (campus interviews, walkin interviews, company interviews), placements, entrance exams and other competitive exams. These questions can be attempted by anyone focusing on learning C Programming language. They can be a beginner, fresher, engineering graduate or an experienced IT professional. Our C quiz comes with detailed explanation of the answers which helps in better understanding of C concepts.

Here is a listing of C quiz on “Automatic Variable” along with answers, explanations and/or solutions:

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
Answer: d
Clarification: None.

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

3. Which of the following is a storage specifier?
a) enum
b) union
c) auto
d) volatile
Answer: c
Clarification: 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
Answer: a
Clarification: None.

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

  1.     #include 
  2.     void foo(auto int i);
  3.     int main()
  4.     {
  5.         foo(10);
  6.     }
  7.     void foo(auto int i)
  8.     {
  9.         printf("%dn", i );
  10.     }

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

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

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

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

  1.     #include 
  2.     int main()
  3.     {
  4.         auto i = 10;
  5.         const auto int *p = &i;
  6.         printf("%dn", i);
  7.     }

a) 10
b) Compile time error
c) Depends on the standard
d) Depends on the compiler
Answer: a
Clarification: None.

contest

Leave a Reply

Your email address will not be published. Required fields are marked *