Pointers in c language: 18 MCQs

All 18 multiple-choice questions from this kit, free and with no sign-up.

Warm-up · 7 questions

Q1. What is the primary purpose of a pointer in C?

Beginner
A To store a floating-point number
B To store a string literal
C To store the memory address of a variable
D To store a character value

Answers and explanations are in the Veda app.

Q2. Which operator is used to declare a pointer variable in C?

Beginner
A *
B ->
C &
D .

Answers and explanations are in the Veda app.

Q3. What does the '&' operator do when applied to a variable?

Beginner
A Multiplies the variable by 2
B Returns the value of the variable
C Returns the memory address of the variable
D Dereferences the pointer

Answers and explanations are in the Veda app.

Q4. Given `int x = 10; int *p = &x;` What is the value of `*p`?

Beginner
A The address of p
B The address of x
C Undefined
D 10

Answers and explanations are in the Veda app.

Q5. What is a null pointer in C?

Beginner
A A pointer that points to a valid memory location
B A pointer that points to a variable with value 0
C A pointer that points to no valid memory location
D A pointer that cannot be dereferenced

Answers and explanations are in the Veda app.

Q6. A pointer variable stores the memory address of another variable.

Beginner
A True
B False

Answers and explanations are in the Veda app.

Q7. The dereference operator (*) is used to get the address of a variable.

Beginner
A True
B False

Answers and explanations are in the Veda app.

Building up · 9 questions

Q8. What is the output of the following code? ```c int a = 5; int *p = &a; *p = 8; printf("%d", a); ```

Intermediate
A 5
B Compilation error
C Address of a
D 8

Answers and explanations are in the Veda app.

Q9. What happens when you dereference a null pointer?

Intermediate
A It causes undefined behavior, often a crash
B It automatically allocates memory
C It returns the address of the null pointer
D It returns 0

Answers and explanations are in the Veda app.

Q10. What is pointer arithmetic?

Intermediate
A Multiplying a pointer by an integer
B Performing arithmetic operations on the value pointed to
C Performing arithmetic operations on the pointer's address
D Adding two pointers together

Answers and explanations are in the Veda app.

Q11. If `int *p` points to an integer array, what does `p + 1` represent?

Intermediate
A The next byte after p
B The address of the next integer element
C The address of the first element
D The value of the next integer element

Answers and explanations are in the Veda app.

Q12. What is the relationship between arrays and pointers in C?

Intermediate
A Arrays are always pointers
B An array name is a constant pointer to its first element
C Arrays store pointers
D Pointers cannot be used with arrays

Answers and explanations are in the Veda app.

Q13. What is a pointer to a pointer?

Intermediate
A A pointer that points to a null value
B A pointer that stores the address of another pointer
C A pointer that points to a constant
D A pointer that points to a function

Answers and explanations are in the Veda app.

Q14. What is the correct way to pass a pointer to a function to modify the original variable?

Intermediate
A Pass the variable name only
B Pass the address of the variable using &
C Pass a copy of the variable
D Pass the value of the variable

Answers and explanations are in the Veda app.

Q15. What is the main advantage of using pointers in C?

Intermediate
A They eliminate the need for variables
B They allow direct memory access and efficient manipulation
C They automatically manage memory
D They make the code shorter

Answers and explanations are in the Veda app.

Q16. What is the correct way to free dynamically allocated memory in C?

Intermediate
A Using the delete keyword
B Using the realloc() function
C Using the malloc() function
D Using the free() function

Answers and explanations are in the Veda app.

Topper level · 2 questions

Q17. What is a function pointer in C?

Advanced
A A pointer that points to a variable
B A function that takes a pointer as an argument
C A pointer that points to a function's code
D A function that returns a pointer

Answers and explanations are in the Veda app.

Q18. What is a dangling pointer?

Advanced
A A pointer that points to a constant
B A pointer that points to a null value
C A pointer that points to a valid variable
D A pointer that points to memory that has been freed or deallocated

Answers and explanations are in the Veda app.

Make your own

Your notes can be a kit like these

Every kit here was made from real study material. Point Veda at a chapter, a PDF, a photo or a link and get notes, flashcards, practice MCQs, games and a scored test — free to start, in more than 40 languages.

  • Chapter notes
  • Flashcards
  • Practice MCQs
  • Scored tests
  • Paper Solver

Get Veda free See what students get

Free to start · Android app and web · More than 40 languages