C Programming Questions and Answers – External Variables – 1

«
»

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

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

advertisement

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

  1.     #include <stdio.h>
  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
View Answer

Answer: b
Explanation: None.
Sanfoundry Certification Contest of the Month is Live. 100+ Subjects. Participate Now!
advertisement
advertisement

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

Check this: BCA MCQs | C Books
advertisement
  1.     #include <stdio.h>
  2.     int x;
  3.     void main()
  4.     {
  5.         printf("%d", x);
  6.     }

a) Junk value
b) Run time error
c) 0
d) Undefined
View Answer

Answer: c
Explanation: None.
advertisement

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

  1.     #include <stdio.h>
  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
View Answer

Answer: d
Explanation: None.
advertisement

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

  1.     #include <stdio.h>
  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
View Answer

Answer: a
Explanation: 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
View Answer

Answer: b
Explanation: None.

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

Answer: b
Explanation: None.

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

  1.     #include <stdio.h>
  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
View Answer

Answer: d
Explanation: None.

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

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

a) 9
b) 10
c) 11
d) Compile time error
View Answer

Answer: d
Explanation: None.

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

  1.     #include <stdio.h>
  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
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.