Log In Register

Units


Address Arithmetic - Questions and Answers

 

Practice these Address Arithmetic  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 Address Arithmetic for following purpose.


– Anyone who is wishing to increase their perfect knowledge of Address Arithmetic of C Programming.
– Anyone who is preparing for aptitude test and increase his in depth aptitude knowledge C Programming specifically Address Arithmetic .
– 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 Address Arithmetic 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  Address Arithmetic topic of C Programming:

 

1.

What is the output of this C code?

  1.     #include <stdio.h>
  2.     void main()
  3.     {
  4.         char *s = "hello";
  5.         char *p = s * 3;
  6.         printf("%c\t%c", *p, s[1]);
  7.     }

Answer: Option B

Explanation:

2.

What is the output of this C code?

  1.     #include <stdio.h>
  2.     void main()
  3.     {
  4.         char *s= "hello";
  5.         char *p = s + 2;
  6.         printf("%c\t%c", *p, s[1]);
  7.     }

Answer: Option D

Explanation:

3.

What is the output of this C code?

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

Answer: Option C

Explanation:

4.

What is the output of this C code?

  1.     #include <stdio.h>
  2.     int main()
  3.     {
  4.         double *ptr = (double *)100;
  5.         ptr = ptr + 2;
  6.         printf("%u", ptr);
  7.     }

Answer: Option A

Explanation:

5.

What is the output of this C code?

  1.     #include <stdio.h>
  2.     int main()
  3.     {
  4.         void *p;
  5.         int a[4] = {1, 2, 3, 8};
  6.         p = &a[3];
  7.         int *ptr = &a[2];
  8.         int n = p - ptr;
  9.         printf("%d\n", n);
  10.     }

Answer: Option C

Explanation:

6.

Comment on the output of this C code?

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

Answer: Option B

Explanation:

7.

What is the output of this C code?

  1.     #include <stdio.h>
  2.     void main()
  3.     {
  4.         char *s = "hello";
  5.         char *p = s;
  6.         printf("%c\t%c", *(p + 1), s[1]);
  7.     }

Answer: Option A

Explanation:

8.

What is the output of this C code?

  1.     #include <stdio.h>
  2.     int main()
  3.     {
  4.         int a[4] = {1, 2, 3, 4};
  5.         void *p = &a[1];
  6.         void *ptr = &a[2];
  7.         int n = 1;
  8.         n = ptr - p;
  9.         printf("%d\n", n);
  10.     }

Answer: Option D

Explanation:

9.

What is the output of this C code?

  1.     #include <stdio.h>
  2.     void main()
  3.     {
  4.         char *s = "hello";
  5.         char *p = s;
  6.         printf("%c\t%c", *p, s[1]);
  7.     }

Answer: Option B

Explanation:

10.

What is the output of this C code?

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

Answer: Option B

Explanation:

11.

What is the output of this C code?

  1.     #include <stdio.h>
  2.     void main()
  3.     {
  4.         char *s = "hello";
  5.         char *n = "cjn";
  6.         char *p = s + n;
  7.         printf("%c\t%c", *p, s[1]);
  8.     }

Answer: Option C

Explanation:

12.

Which of following logical operation can be applied to pointers?
    (Assuming initialization int *a = 2; int *b = 3;)

Answer: Option D

Explanation:

13.

What is the output of this C code?

  1.     #include <stdio.h>
  2.     int main()
  3.     {
  4.         int a[4] = {1, 2, 3, 4};
  5.         int b[4] = {1, 2, 3, 4};
  6.         int n = &b[3] - &a[2];
  7.         printf("%d\n", n);
  8.     }

Answer: Option D

Explanation:

14.

What is the output of this C code?

  1.     #include <stdio.h>
  2.     int main()
  3.     {
  4.         void *p;
  5.         int a[4] = {1, 2, 3, 4};
  6.         p = &a[3];
  7.         int *ptr = &a[2];
  8.         int n = (int*)p - ptr;
  9.         printf("%d\n", n);
  10.     }

Answer: Option D

Explanation:

15.

What is the size of *ptr in a 32-bit machine, (assuming initialization as int *ptr = 10;)?

Answer: Option B

Explanation: