Pointers in C Language: 18 MCQs

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

Warm-up · 6 questions

Q1. What is a pointer in C?

Beginner
A A data type that stores text
B A keyword that frees memory
C A function that allocates memory
D A variable that stores a memory address

Answers and explanations are in the Veda app.

Q2. Which operator returns the address of a variable?

Beginner
A `*`
B `&`
C `->`
D `%`

Answers and explanations are in the Veda app.

Q3. What does the `*` operator do when applied to a pointer?

Beginner
A Multiplies the pointer by two
B Dereferences it to access the value at that address
C Returns the address of the pointer itself
D Frees the memory the pointer references

Answers and explanations are in the Veda app.

Q4. Which line correctly declares a pointer to an int?

Beginner
A `int p*;`
B `pointer int p;`
C `int &p;`
D `int *p;`

Answers and explanations are in the Veda app.

Q5. In C, an array name in most expressions behaves like:

Beginner
A A pointer to its last element
B A null pointer
C A copy of the whole array
D A pointer to its first element

Answers and explanations are in the Veda app.

Q6. In C, an array name is not a pointer but decays to a pointer to its first element in most expressions.

Beginner
A True
B False

Answers and explanations are in the Veda app.

Building up · 7 questions

Q7. If `int` is 4 bytes, how far does `p + 1` advance for an `int *p`?

Intermediate
A 1 byte
B 4 bytes
C 8 bytes
D 2 bytes

Answers and explanations are in the Veda app.

Q8. Why does `scanf("%d", &x);` need the `&`?

Intermediate
A `&` frees memory before reading
B `scanf` needs the value of `x` to compare
C `scanf` needs the address to store the input into `x`
D `&` converts the input to a string

Answers and explanations are in the Veda app.

Q9. What is the effect of `void increment(int *n) { (*n)++; }` called as `increment(&x);`?

Intermediate
A The program crashes because `x` is not a pointer
B `x` is incremented in the caller
C `x` becomes a pointer
D A copy of `x` is incremented and discarded

Answers and explanations are in the Veda app.

Q10. What does `malloc` return on success?

Intermediate
A A null pointer always
B A pointer to stack memory
C The size of the allocated block
D A pointer to heap memory

Answers and explanations are in the Veda app.

Q11. What is a dangling pointer?

Intermediate
A A pointer that points to the stack
B A pointer that has never been declared
C A pointer that still holds the address of memory already freed
D A pointer that is always `NULL`

Answers and explanations are in the Veda app.

Q12. What does `int **pp;` declare?

Intermediate
A A pointer to a pointer to an int
B An int with two stars in its name
C Two separate int pointers
D A pointer to an array of ints

Answers and explanations are in the Veda app.

Q13. What is wrong with `int *a, b;` if you wanted two pointers?

Intermediate
A Neither `a` nor `b` is a pointer
B Only `a` is a pointer; `b` is an int
C Both `a` and `b` are pointers
D The compiler rejects the line

Answers and explanations are in the Veda app.

Topper level · 5 questions

Q14. Why must you check a pointer for `NULL` before dereferencing?

Advanced
A `NULL` pointers automatically allocate memory
B Checking converts the pointer to an int
C Dereferencing `NULL` is undefined behavior and typically crashes
D `NULL` pointers always point to valid stack memory

Answers and explanations are in the Veda app.

Q15. What is the difference between `*p = &x;` and `p = &x;`?

Advanced
A Both are correct and equivalent
B Both are type errors
C `*p = &x;` is a type error; `p = &x;` is correct
D `p = &x;` is a type error; `*p = &x;` is correct

Answers and explanations are in the Veda app.

Q16. Which statement about `sizeof(arr)` versus `sizeof(ptr)` is correct?

Advanced
A `sizeof(ptr)` gives total array size; `sizeof(arr)` gives pointer size
B `sizeof` cannot be applied to arrays
C `sizeof(arr)` gives total array size; `sizeof(ptr)` gives pointer size
D Both always give the same value

Answers and explanations are in the Veda app.

Q17. Given the following code snippet, what will be the output when `printf("%d", **pp);` is executed? ```c int x = 5; int *p = &x; int **pp = &p; ```

Advanced
A Undefined behavior
B Address of p
C 5
D Address of x

Answers and explanations are in the Veda app.

Q18. Consider the following code segment. What will happen when `free(arr);` is called? ```c int *arr = malloc(10 * sizeof(int)); if (arr != NULL) { for (int i = 0; i < 10; i++) { arr[i] = i; } } free(arr); arr[0] = 100; // What is the consequence of this line? ```

Advanced
A The program will run without issues.
B It will cause a memory leak.
C The program will crash.
D The value 100 will be assigned to arr[0].

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, in 42 languages.

  • Chapter notes
  • Flashcards
  • Practice MCQs
  • Scored tests
  • Exam prep

Get Veda free See what students get

Free to start · No ads · Works in 42 languages