Log In Register

Units


Pointers And Addresses - Questions and Answers

 

Practice these Pointers And Addresses under C Programming walk-in interview Questions/ examination questions with best tricks and short cuts with solution. Student (candidate) who want to crack the walk in interview, competitive exams and want to find short cuts and tricks to solve questions on Pointers And Addresses for following purpose.


– Anyone who is wishing to increase their perfect knowledge of Pointers And Addresses of C Programming.
– Anyone who is preparing for aptitude test and increase his in depth aptitude knowledge C Programming specifically Pointers And Addresses.
– Anyone who is preparing for interviews (competitive examinations, govt examinations and bank examinations, off-campus or on campus interviews, walk-in interview and company interviews) having questions on Pointers And Addresses under C Programming.

– Anyone who is preparing for aptitude test or competitive exam or entrance exam.
– Anyone who is preparing for entrance examinations and other competitive examinations.
– All Experienced, Freshers and Students.

Here is list of Questions and Answers covering all key area of  Pointers And Addresses topic of C Programming:

 

1.

What is the output of this C code?

  1.     #include <stdio.h>
  2.     int main()
  3.     {
  4.         int *ptr, a = 10;
  5.         ptr = &a;
  6.         *ptr += 1;
  7.         printf("%d,%d/n", *ptr, a);
  8.     }

Answer: Option A

Explanation:

2.

Which is an indirection operator among the following?

Answer: Option C

Explanation:

3.

What is the output of this C code?

  1.     #include <stdio.h>
  2.     int *f();
  3.     int main()
  4.     {
  5.         int *p = f();
  6.         printf("%d\n", *p);
  7.     }
  8.     int *f()
  9.     {
  10.         int *j = (int*)malloc(sizeof(int));
  11.         *j = 10;
  12.         return j;
  13.     }

Answer: Option D

Explanation:

4.

What is the output of this C code?

  1.     #include <stdio.h>
  2.     void main()
  3.     {
  4.         int x = 0;
  5.         int *ptr = &x;
  6.         printf("%d\n", *ptr);
  7.     }

Answer: Option B

Explanation:

5.

What is the output of this C code?

  1.     #include <stdio.h>
  2.     int main()
  3.     {
  4.         int i = 10;
  5.         void *p = &i;
  6.         printf("%f\n", *(float*)p);
  7.         return 0;
  8.     }

Answer: Option A

Explanation:

6.

What is the output of this C code?

  1.     #include <stdio.h>
  2.     int main()
  3.     {
  4.         int i = 10;
  5.         void *p = &i;
  6.         printf("%d\n", (int)*p);
  7.         return 0;
  8.     }

Answer: Option B

Explanation:

7.

Comment on the following?
    const int *ptr;

Answer: Option D

Explanation:

8.

Comment on the following pointer declaration?
    int *ptr, p;

Answer: Option D

Explanation:

9.

Which of the following does not initialize ptr to null (assuming variable declaration of a as int     a=0;?

Answer: Option C

Explanation:

10.

What is the output of this C code?

  1.     #include <stdio.h>
  2.     int x = 0;
  3.     void main()
  4.     {
  5.         int *ptr = &x;
  6.         printf("%p\n", ptr);
  7.         x++;
  8.         printf("%p\n ", ptr);
  9.     }

Answer: Option D

Explanation:

11.

What is the output of this C code?

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

Answer: Option C

Explanation:

12.

What is the output of this C code?

  1.     #include <stdio.h>
  2.     void main()
  3.     {
  4.         int x = 0;
  5.         int *ptr = &x;
  6.         printf("%p\n", ptr);
  7.         ptr++;
  8.         printf("%p\n ", ptr);
  9.     }

Answer: Option D

Explanation:

13.

What is the output of this C code?

  1.     #include <stdio.h>
  2.     int *f();
  3.     int main()
  4.     {
  5.         int *p = f();
  6.         printf("%d\n", *p);
  7.     }
  8.     int *f()
  9.     {
  10.         int j = 10;
  11.         return &j;
  12.     }

Answer: Option B

Explanation:

14.

What is the output of this C code?

  1.     #include <stdio.h>
  2.     int main()
  3.     {
  4.         char *p = NULL;
  5.         char *q = 0;
  6.         if (p)
  7.             printf(" p ");
  8.         else
  9.             printf("nullp");
  10.         if (q)
  11.             printf("q\n");
  12.         else
  13.             printf(" nullq\n");
  14.     }

Answer: Option D

Explanation: