250+ TOP MCQs on External Variables and Answers

C questions and puzzles on “External Variables”. One shall practice these questions and puzzles to improve their C programming skills needed for various interviews (campus interviews, walkin interviews, company interviews), placements, entrance exams and other competitive exams. These programming puzzles 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 questions come with detailed explanation of the answers which helps in better understanding of C concepts.

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

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

  1.     #include 
  2.     void main()
  3.     {
  4.         m();
  5.         printf("%d", x);
  6.     }
  7.     int x;
  8.     void m()
  9.     {
  10.         x = 4;
  11.     }

a) 4
b) Compile time error
c) 0
d) Undefined
Answer: b
Clarification: None.

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

  1.     #include 
  2.     int x;
  3.     void main()
  4.     {
  5.         printf("%d", x);
  6.     }

a) Junk value
b) Run time error
c) 0
d) Undefined
Answer: c
Clarification: None.

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

  1.     #include 
  2.     int x = 5;
  3.     void main()
  4.     {
  5.         int x = 3;
  6.         printf("%d", x);
  7.         {
  8.             x = 4;
  9.         }
  10.         printf("%d", x);
  11.     }

a) Run time error
b) 3 3
c) 3 5
d) 3 4
Answer: d
Clarification: None.

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

  1.     #include 
  2.     int x = 5;
  3.     void main()
  4.     {
  5.         int x = 3;
  6.         printf("%d", x);
  7.         {
  8.             int x = 4;
  9.         }
  10.         printf("%d", x);
  11.     }

a) 3 3
b) 3 4
c) 3 5
d) Run time error
Answer: a
Clarification: None.

5. Functions in C are always _________
a) Internal
b) External
c) Both Internal and External
d) External and Internal are not valid terms for functions
Answer: b
Clarification: None.

6. Global variables are ____________
a) Internal
b) External
c) Both Internal and External
d) None of the mentioned
Answer: b
Clarification: None.

7. Which of the following is an external variable in the following C code?

  1.     #include 
  2.     int func (int a)
  3.     {
  4.         int b;
  5.         return b;
  6.     }
  7.     int main()
  8.     {
  9.         int c;
  10.         func (c);
  11.     }
  12.     int d;

a) a
b) b
c) c
d) d
Answer: d
Clarification: None.

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

  1.      #include 
  2.     int main()
  3.     {
  4.         printf("%d", d++);
  5.     }
  6.     int d = 10;

a) 9
b) 10
c) 11
d) Compile time error
Answer: d
Clarification: None.

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

  1.     #include 
  2.     double var = 8;
  3.     int main()
  4.     {
  5.         int var = 5;
  6.         printf("%d", var);
  7.     }

a) 5
b) 8
c) Compile time error due to wrong format identifier for double
d) Compile time error due to redeclaration of variable with same name
Answer: a
Clarification: None.

Leave a Reply

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