Which operator is used to get the address of a variable in C?
A * B & C -> D .
The & operator (address-of operator) returns the memory address of a variable.
What will be the size of a pointer variable on a 64-bit system?
A 2 bytes B 4 bytes C 8 bytes D 16 bytes
On a 64-bit system, a pointer is 8 bytes (64 bits) regardless of the data type it points to.
What is a NULL pointer?
A Pointer pointing to address 0 B Uninitialized pointer C Pointer with no name D Invalid pointer
A NULL pointer is a pointer that points to memory address 0, indicating it doesn't point to any valid memory location.
What is the output? int a = 5; int *p = &a; int **q = &p; printf("%d", **q);
A 5 B Address of a C Address of p D Compilation error
q is a pointer to pointer p. **q dereferences q to get p, then dereferences p to get the value 5.
What happens when you increment a pointer? int arr[5] = {1,2,3,4,5}; int *p = arr; p++;
A p points to the next byte in memory B p points to the next element of the array C p's value increases by 1 D Compilation error
When a pointer is incremented, it moves to the next element based on the data type size (pointer arithmetic).
Which of the following is NOT a valid pointer declaration?
A int *p; B float *q; C void *r; D int &s;
& is a reference operator used in C++, not in C. In C, pointers are declared using *.
What is the output? int x = 10, y = 20; int *p = &x; int *q = &y; p = q; printf("%d", *p);
A 10 B 20 C Address of y D Garbage value
After p = q, pointer p now points to y. So *p gives the value of y, which is 20.
Identify the output: char *str = "Hello"; printf("%c", *str);
A H B Hello C e D Address
*str dereferences the pointer to get the first character of the string, which is 'H'.
What is the difference between *p++ and (*p)++?
A No difference B *p++ increments pointer, (*p)++ increments value C (*p)++ increments pointer, *p++ increments value D Syntax error
Due to operator precedence, *p++ is equivalent to *(p++), incrementing the pointer. (*p)++ explicitly increments the value.
What will be printed? int arr[] = {1, 2, 3}; int *p = arr; printf("%d", *(p+2));
A 1 B 2 C 3 D Garbage value
p+2 points to the third element of the array. *(p+2) dereferences it to get 3.
What is a wild pointer?
A Pointer pointing to NULL B Uninitialized pointer with garbage address C Pointer in a wildlife program D Pointer declared inside a loop
A wild pointer is an uninitialized pointer that contains an arbitrary/garbage memory address.
What is the output? int *p = NULL; if(p) printf("Not NULL"); else printf("NULL");
A Not NULL B NULL C Segmentation fault D Compilation error
NULL pointer evaluates to false in a conditional, so the else block executes.
Which of the following correctly allocates memory for 10 integers?
A int *p = malloc(10); B int *p = malloc(10 * sizeof(int)); C int *p = malloc(sizeof(int)); D int *p = alloc(10);
malloc requires the size in bytes. For 10 integers, we need 10 * sizeof(int) bytes.
What is a dangling pointer?
A Pointer pointing to freed memory B NULL pointer C Uninitialized pointer D Pointer declared outside main()
A dangling pointer is a pointer that points to memory that has been freed or deallocated.
What does the following code do? int *p = (int*)malloc(sizeof(int)); *p = 5; free(p); p = NULL;
A Allocates, assigns, deallocates and nullifies pointer B Creates a memory leak C Causes segmentation fault D Compilation error
This is proper memory management: allocate, use, free, and nullify to prevent dangling pointer.
What will be the output? int arr[] = {10, 20, 30}; int *p = arr; printf("%d %d", arr[1], *(p+1));
A 20 20 B 20 10 C 10 20 D 30 20
arr[1] and *(p+1) both access the second element of the array, which is 20.
Which statement is true about void pointers?
A Cannot be dereferenced without casting B Can only point to void type C Are always NULL D Cannot be incremented
void pointers are generic pointers that must be cast to appropriate type before dereferencing.
What is the output? int x = 50; int *p = &x; int *q = p; q = NULL; printf("%d", *p);
A 50 B NULL C Garbage value D Segmentation fault
Setting q to NULL doesn't affect p. p still points to x, so *p is 50.
A pointer variable stores the _____ of another variable.
A value B memory address C data type D size
Pointers store memory addresses of variables. The address-of operator (&) retrieves this address.
What is the size of a pointer variable on a 32-bit system?
A 2 bytes B 4 bytes C 8 bytes D Depends on the data type
On a 32-bit system, all pointers are 4 bytes (32 bits) regardless of the data type they point to.