C Programming Questions and Answers on Pointers to Pointers for Freshers

1. What is the output of this C code?
  1.     #include 
  2.     void main()
  3.     {
  4.         int k = 5;
  5.         int *p = &k;
  6.         int **m  = &p;
  7.         printf("%d%d%d\n", k, *p, **m);
  8.     }
a) 5 5 5
b) 5 5 junk value
c) 5 junk junk
d) Run time error
Answer: a
2. What is the output of this C code?
  1.     #include 
  2.     void main()
  3.     {
  4.         int k = 5;
  5.         int *p = &k;
  6.         int **m  = &p;
  7.         printf("%d%d%d\n", k, *p, **p);
  8.     }
a) 5 5 5
b) 5 5 junk value
c) 5 junk junk
d) Compile time error
Answer: d
3. What is the output of this C code?

  1.     #include 
  2.     void main()
  3.     {
  4.         int k = 5;
  5.         int *p = &k;
  6.         int **m  = &p;
  7.         **m = 6;
  8.         printf("%d\n", k);
  9.     }
a) 5
b) Compile time error
c) 6
d) Junk
Answer: c
4. What is the output of this C code?

  1.     #include 
  2.     void main()
  3.     {
  4.         int a[3] = {1, 2, 3};
  5.         int *p = a;
  6.         int *r = &p;
  7.         printf("%d", (**r));
  8.     }
a) 1
b) Compile time error
c) Address of a
d) Junk value
Answer: b
5. What is the output of this C code?

  1.     #include 
  2.     void main()
  3.     {
  4.         int a[3] = {1, 2, 3};
  5.         int *p = a;
  6.         int **r = &p;
  7.         printf("%p %p", *r, a);
  8.     }
a) Different address is printed
b) 1 2
c) Same address is printed.
d) 1 1
Answer: c
6. How many number of pointer (*) does C have against a pointer variable declaration?

a) 7
b) 127
c) 255
d) No limits.
Answer: d
7. What is the output of this C code?

  1.     #include 
  2.     int main()
  3.     {
  4.         int a = 1, b = 2, c = 3;
  5.         int *ptr1 = &a, *ptr2 = &b, *ptr3 = &c;
  6.         int **sptr = &ptr1; //-Ref
  7.         *sptr = ptr2;
  8.     }
a) ptr1 points to a
b) ptr1 points to b
c) sptr points to ptr2
d) None of the mentioned
Answer: b
8. What is the output of this C code?

  1.     #include 
  2.     void main()
  3.     {
  4.         int a[3] = {1, 2, 3};
  5.         int *p = a;
  6.         int **r = &p;
  7.         printf("%p %p", *r, a);
  8.     }
a) Different address is printed
b) 1 2
c) Same address is printed.
d) 1 1
Answer: c
9. What substitution should be made to //-Ref such that ptr1 points to variable C?
  1.     #include 
  2.     int main()
  3.     {
  4.         int a = 1, b = 2, c = 3;
  5.         int *ptr1 = &a;
  6.         int **sptr = &ptr1;
  7.         //-Ref
  8.     }
a) *sptr = &c;
b) **sptr = &c;
c) *ptr1 = &c;
d) none of the mentioned.
Answer: a
10. Which of the following declaration throw run-time error?

a) int **c = &c;
b) int **c = &*c;
c) int **c = **c;
d) none of the mentioned
Answer: d
11. Comment on the output of this C code?
  1.     #include 
  2.     int main()
  3.     {
  4.         int a = 10;
  5.         int **c -= &&a;
  6.     }
a) You cannot apply any arithmetic operand to a pointer
b) We don’t have address of an address operator
c) We have address of an address operator
d) None of the mentioned.
Answer: b
12. What is the output of this C code?
  1.     #include 
  2.     void main()
  3.     {
  4.         int k = 5;
  5.         int *p = &k;
  6.         int **m  = &p;
  7.         printf("%d%d%d\n", k, *p, **m);
  8.     }
a) 5 5 5
b) 5 5 junk value
c) 5 junk junk
d) Compile time error
Answer: a
13. What is the output of this C code?
  1.     #include 
  2.     void main()
  3.     {
  4.         int k = 5;
  5.         int *p = &k;
  6.         int **m  = &p;
  7.         printf("%d%d%d\n", k, *p, **p);
  8.     }
a) 5 5 5
b) 5 5 junk value
c) 5 junk junk
d) Compile time error
Answer: d
14. What is the output of this C code?
  1.     #include 
  2.     void main()
  3.     {
  4.         int k = 5;
  5.         int *p = &k;
  6.         int **m  = &p;
  7.         **m = 6;
  8.         printf("%d\n", k);
  9.     }
a) 5
b) Run time error
c) 6
d) Junk
Answer: c
15. What is the output of this C code?
  1.     #include 
  2.     void main()
  3.     {
  4.         int a[3] = {1, 2, 3};
  5.         int *p = a;
  6.         int *r = &p;
  7.         printf("%d", (**r));
  8.     }
a) 1
b) Compile time error
c) Address of a
d) Junk value
Answer: b

Related

HTML Multiple Choice Questions & Answers on Web Browsers for Freshers

1. Rendering engine is not responsible for a) parsing the markup content (HTML)b) parsing style information (CSS, XSL, and so on)c) generating a visual presentation of the formatted content includi...

Data Structure Questions and Answers on Reverse of a String using Recursion

1. Consider the following iterative implementation used to reverse a string: #include #include void reverse_string(char *s) { int len = strlen(s); int i,j; i=0; j=len-1...

Java Multiple Choice Questions & Answers on Arrays for Freshers

1. Which of these operators is used to allocate memory to array variable in Java? a) mallocb) allocc) newd) new malloc Answer:c Explanation:Operator new allocates block of memory specified by the...

Post a Comment

emo-but-icon
:noprob:
:smile:
:shy:
:trope:
:sneered:
:happy:
:escort:
:rapt:
:love:
:heart:
:angry:
:hate:
:sad:
:sigh:
:disappointed:
:cry:
:fear:
:surprise:
:unbelieve:
:shit:
:like:
:dislike:
:clap:
:cuff:
:fist:
:ok:
:file:
:link:
:place:
:contact:

item