Home Subjects C Programming Pointers

C Programming
Pointers

C language from basics to advanced placement prep

100 Q 10 Topics Take Test
Advertisement
Difficulty: All Easy Medium Hard 61–70 of 100
Topics in C Programming
Q.61 Medium Pointers
What is the difference between pointer and array name in C?
A No difference, both are same
B Array name is a pointer constant, cannot be modified
C Pointer can store any address, array name stores only array address
D Arrays are faster than pointers
Correct Answer:  B. Array name is a pointer constant, cannot be modified
EXPLANATION

Array names are pointer constants that point to the first element and cannot be reassigned, while pointer variables can be modified to point to different addresses.

Take Test
Q.62 Easy Pointers
Which of the following is a void pointer?
A A pointer that points to nothing
B A generic pointer that can point to any data type
C A pointer declared as void variable
D A pointer that has been deleted
Correct Answer:  B. A generic pointer that can point to any data type
EXPLANATION

void* is a generic pointer that can hold addresses of any data type and requires explicit typecasting when used.

Take Test
Q.63 Easy Pointers
What is the output of the following code?
int x = 20;
int *p = &x;
printf("%d", *p);
A Address of x
B 20
C Garbage value
D Compilation error
Correct Answer:  B. 20
EXPLANATION

The * operator dereferences the pointer p, accessing the value it points to, which is 20.

Take Test
Q.64 Easy Pointers
What does the & operator do when used with a variable?
A Returns the value of the variable
B Returns the address of the variable
C Creates a copy of the variable
D Deallocates memory
Correct Answer:  B. Returns the address of the variable
EXPLANATION

The & (address-of) operator returns the memory address of the variable.

Take Test
Q.65 Easy Pointers
What is the size of a pointer variable in a 64-bit system?
A 8 bytes
B 4 bytes
C Depends on data type
D 16 bytes
Correct Answer:  A. 8 bytes
EXPLANATION

In a 64-bit system, all pointers occupy 8 bytes regardless of the data type they point to.

Take Test
Q.66 Hard Pointers
A programmer uses a pointer variable but forgets to initialize it before dereferencing. Which type of error will occur?
A Compile-time error
B Syntax error
C Runtime error or undefined behavior
D Logical error
Correct Answer:  C. Runtime error or undefined behavior
EXPLANATION

Uninitialized pointers contain garbage values. Dereferencing them accesses arbitrary memory locations, causing runtime errors or undefined behavior.

Take Test
Q.67 Hard Pointers
Consider: int *p = (int *)malloc(5 * sizeof(int)); for(int i=0; i
A delete p;
B free(p);
C free(&p);
D p = NULL;
Correct Answer:  B. free(p);
EXPLANATION

malloc() allocated memory must be freed using free(p), not free(&p). After freeing, it's good practice to set p = NULL.

Take Test
Q.68 Hard Pointers
In a function that returns a pointer, which of the following is UNSAFE?
A Returning a pointer to dynamically allocated memory (malloc)
B Returning a pointer to a local variable
C Returning a pointer to a global variable
D Returning a pointer to a static variable
Correct Answer:  B. Returning a pointer to a local variable
EXPLANATION

Returning a pointer to a local variable is unsafe because the variable ceases to exist after the function returns, creating a dangling pointer.

Take Test
Q.69 Medium Pointers
What will be the output of: int x = 10; int *p = &x; printf("%p", p); (assuming typical system output)
A 10
B A memory address in hexadecimal format
C The size of integer
D Error: invalid format specifier
Correct Answer:  B. A memory address in hexadecimal format
EXPLANATION

The %p format specifier prints the pointer value as a memory address in hexadecimal format, not the dereferenced value.

Take Test
Q.70 Medium Pointers
Consider: void func(int *arr, int size); This function prototype suggests that func will:
A Create a new array inside the function
B Modify the original array passed from the caller
C Only read the array values
D Return the array to the caller
Correct Answer:  B. Modify the original array passed from the caller
EXPLANATION

Since an array pointer is passed, the function can access and modify the original array elements in the caller's scope.

Take Test
IGET
iget AI
Online · Ask anything about exams
Hi! 👋 I'm your iget AI assistant.

Ask me anything about exam prep, MCQ solutions, study tips, or strategies! 🎯
UPSC strategy SSC CGL syllabus Improve aptitude NEET Biology tips