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?
BeginnerAnswers and explanations are in the Veda app.
Q2. Which operator returns the address of a variable?
BeginnerAnswers and explanations are in the Veda app.
Q3. What does the `*` operator do when applied to a pointer?
BeginnerAnswers and explanations are in the Veda app.
Q4. Which line correctly declares a pointer to an int?
BeginnerAnswers and explanations are in the Veda app.
Q5. In C, an array name in most expressions behaves like:
BeginnerAnswers 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.
BeginnerAnswers 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`?
IntermediateAnswers and explanations are in the Veda app.
Q8. Why does `scanf("%d", &x);` need the `&`?
IntermediateAnswers and explanations are in the Veda app.
Q9. What is the effect of `void increment(int *n) { (*n)++; }` called as `increment(&x);`?
IntermediateAnswers and explanations are in the Veda app.
Q10. What does `malloc` return on success?
IntermediateAnswers and explanations are in the Veda app.
Q11. What is a dangling pointer?
IntermediateAnswers and explanations are in the Veda app.
Q12. What does `int **pp;` declare?
IntermediateAnswers and explanations are in the Veda app.
Q13. What is wrong with `int *a, b;` if you wanted two pointers?
IntermediateAnswers and explanations are in the Veda app.
Topper level · 5 questions
Q14. Why must you check a pointer for `NULL` before dereferencing?
AdvancedAnswers and explanations are in the Veda app.
Q15. What is the difference between `*p = &x;` and `p = &x;`?
AdvancedAnswers and explanations are in the Veda app.
Q16. Which statement about `sizeof(arr)` versus `sizeof(ptr)` is correct?
AdvancedAnswers 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; ```
AdvancedAnswers 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? ```
AdvancedAnswers and explanations are in the Veda app.
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