Pointers Interview Questions

    Question 1Pointer Basics

    What does a pointer variable store in C?

    Question 2Declaring a Pointer

    Which of the following correctly declares a pointer to an integer?

    Question 3Pointer Dereferencing

    What will be the output of this program?

    #include <stdio.h> int main() { int x = 10; int *p = &x; printf("%d", *p); return 0; }

    Question 4Pointer Assignment

    What will be printed?

    #include <stdio.h> int main() { int a = 5, b = 20; int *p = &a; p = &b; printf("%d", *p); return 0; }

    Question 5NULL Pointer

    What does a NULL pointer represent in C?

    Question 6Pointer and Array

    What will be the output?

    #include <stdio.h> int main() { int arr[] = {10, 20, 30}; int *p = arr; printf("%d", *(p+1)); return 0; }

    Question 7Pointer Arithmetic

    If p is an integer pointer pointing to address 1000, what will p+1 point to (assuming 4-byte int)?

    Question 8Double Pointer

    What will be the output?

    #include <stdio.h> int main() { int x = 42; int *p = &x; int **q = &p; printf("%d", **q); return 0; }

    Question 9Dangling Pointer

    When does a dangling pointer occur in C?

    Question 10Function Pointers

    Which is the correct syntax to declare a pointer to a function that takes int as argument and returns int?