Units

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.

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

Explanation:

2.

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. `    }`

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. `    }`

Explanation:

4.

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. `    }`

Explanation:

5.

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. `    }`

Explanation:

6.

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. `    }`

Explanation:

7.

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. `    }`

Explanation:

8.

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. `    }`

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 + 1), s[1]);`
7. `    }`

Explanation:

10.

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. `    }`

Explanation:

11.

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. `    }`

Explanation:

12.

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. `    }`

Explanation:

13.

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. `    }`

Explanation:

14.

Which of the following operand can be applied to pointers p and q?
(Assuming initialization as int *a = (int *)2; int *b = (int *)3;)

Explanation:

15.

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. `    }`