LearnFrenzy
Sign in Take a free test

Pointers · Exercise 1 of 4

Pointers Pointer Basics MCQ

  • 12 questions
  • Page 1 of 2
  • Answers explained
0Attempted
0Correct
0Wrong
Directions

Twelve multiple-choice questions on what pointers are, the & and * operators, NULL, void and const pointers. Pick an option to check your answer instantly.

Question 1 Easy

A pointer in C is a variable that stores…

A the value of another variable
B the memory address of another variable
C the name of another variable
D the data type of another variable
Question page & discussion
Question 2 Easy

Which operator gives the address of a variable?

A *
B &
C ->
D %
Question page & discussion
Question 3 Easy

If p holds the address of x, which expression gives the value of x?

A &p
B p
C *p
D **p
Question page & discussion
Question 4 Easy

After the declaration int *p, q; what are p and q?

A both are pointers to int
B p is a pointer to int, q is an int
C p is an int, q is a pointer to int
D it is a compile error
Question page & discussion
Question 5 Easy

On a typical 64-bit system, what is sizeof(char *) compared with sizeof(double *)?

A 1 and 8 bytes
B 4 and 8 bytes
C 8 bytes each
D it depends on the values stored
Question page & discussion
Question 6 Easy

Which statement about a NULL pointer is true?

A It points to address 0, which stores the value 0
B It points to no valid object, and dereferencing it is undefined behaviour
C It is the same as an uninitialised pointer
D It can only be used with char pointers
Question page & discussion
Question 7 Medium

int *p holds the address 1000 and an int is 4 bytes. What address does p + 1 hold?

A 1001
B 1004
C 1008
D 1000
Question page & discussion
Question 8 Easy

For an array a, the expression a[i] is equivalent to…

A *a + i
B *(a + i)
C &a + i
D *(&a + i)
Question page & discussion
Question 9 Medium

Which is true about void *vp?

A It can hold the address of any object, but must be converted before it is dereferenced
B It always holds NULL
C It can be dereferenced directly with *vp
D It is the same as a function pointer
Question page & discussion
Question 10 Medium

A dangling pointer is a pointer that…

A has never been given a value
B holds NULL
C still points to memory that has been freed or has gone out of scope
D points to another pointer
Question page & discussion

Ready to test your Programming?

Timed online tests with instant scores and explanations.

Search LearnFrenzy

Esc

Quick links