250+ TOP MCQs on Pointers and Addresses and Answers

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

Here is a listing of online C test questions on “Pointers and Addresses” along with answers, explanations and/or solutions:

1. Which is an indirection operator among the following?
a) &
b) *
c) ->
d) .
Answer: b
Clarification: None.

2. Which of the following does not initialize ptr to null (assuming variable declaration of a as int a=0;)?
a) int *ptr = &a;
b) int *ptr = &a – &a;
c) int *ptr = a – a;
d) All of the mentioned
Answer: a
Clarification: None.

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

  1.     #include 
  2.     int x = 0;
  3.     void main()
  4.     {
  5.         int *ptr = &x;
  6.         printf("%pn", ptr);
  7.         x++;
  8.         printf("%pn ", ptr);
  9.     }

a) Same address
b) Different address
c) Compile time error
d) Varies
Answer: a
Clarification: None.

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

  1.     #include 
  2.     int x = 0;
  3.     void main()
  4.     {
  5.         int *const ptr = &x;
  6.         printf("%pn", ptr);
  7.         ptr++;
  8.         printf("%pn ", ptr);
  9.     }

a) 0 1
b) Compile time error
c) 0xbfd605e8 0xbfd605ec
d) 0xbfd605e8 0xbfd605e8
Answer: b
Clarification: None.

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

  1.     #include 
  2.     void main()
  3.     {
  4.         int x = 0;
  5.         int *ptr = &x;
  6.         printf("%pn", ptr);
  7.         ptr++;
  8.         printf("%pn ", ptr);
  9.     }

a) 0xbfd605e8 0xbfd605ec
b) 0xbfd605e8 0cbfd60520
c) 0xbfd605e8 0xbfd605e9
d) Run time error
Answer: a
Clarification: None.

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

  1.     #include 
  2.     void main()
  3.     {
  4.         int x = 0;
  5.         int *ptr = &5;
  6.         printf("%pn", ptr);
  7.     }

a) 5
b) Address of 5
c) Nothing
d) Compile time error
Answer: d
Clarification: None.

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

  1.     #include 
  2.     void main()
  3.     {
  4.         int x = 0;
  5.         int *ptr = &x;
  6.         printf("%dn", *ptr);
  7.     }

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

  250+ TOP MCQs on If-then-else Statements and Answers

Leave a Comment

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

Scroll to Top