250+ TOP MCQs on External Variables and Answers

C helps anyone preparing for Cognizant and other companies C interviews. One should practice these Objective Questions and answers continuously for 2-3 months to clear Cognizant interviews on C Programming language.

Here is a listing of basic C Objective Questions on “External Variable” along with answers, explanations and/or solutions:

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

  1.     #include 
  2.     double i;
  3.     int main()
  4.     {
  5.        printf("%gn",i);
  6.        return 0;
  7.     }

a) 0
b) 0.000000
c) Garbage value
d) Depends on the compiler
Answer: a
Clarification: None.

2. Which part of the program address space is p stored in the following C code?

  1.     #include 
  2.     int *p = NULL;
  3.     int main()
  4.     {
  5.         int i = 0;
  6.         p = &i;
  7.         return 0;
  8.     }

a) Code/text segment
b) Data segment
c) Bss segment
d) Stack
Answer: b
Clarification: None.

3. Which part of the program address space is p stored in the following C code?

  1.     #include 
  2.     int *p;
  3.     int main()
  4.     {
  5.         int i = 0;
  6.         p = &i;
  7.         return 0;
  8.     }

a) Code/text segment
b) Data segment
c) Bss segment
d) Stack
Answer: c
Clarification: None.

4. Can variable i be accessed by functions in another source file?

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

a) Yes
b) No
c) Only if static keyword is used
d) Depends on the type of the variable
Answer: a
Clarification: None.

5. Property of the external variable to be accessed by any source file is called by the C90 standard as __________
a) external linkage
b) external scope
c) global scope
d) global linkage
Answer: a
Clarification: None.

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

  1.     #include 
  2.     int *i;
  3.     int main()
  4.     {
  5.         if (i == NULL)
  6.             printf("truen");
  7.         return 0;
  8.     }

a) true
b) true only if NULL value is 0
c) Compile time error
d) Nothing
Answer: a
Clarification: None.

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

  1.     #include 
  2.     int *i;
  3.     int main()
  4.     {
  5.         if (i == 0)
  6.             printf("truen");
  7.         return 0;
  8.     }

a) true
b) true only if NULL value is 0
c) Compile time error
d) Nothing
Answer: b
Clarification: None.

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

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

a) 9
b) 4
c) 5
d) 0
Answer: a
Clarification: None.

  250+ TOP MCQs on Endianness and Answers

Leave a Comment

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

Scroll to Top