Multiple choice technology programming languages

I want to declare a pointer to a constant int variable ,pointing to a constant memory location. What is the syntax?

  1. const int* ptr

  2. const* int ptr

  3. There is no such declaration like that

  4. const int* const ptr

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

The syntax const int* const ptr declares a pointer to a const int where both the pointer and the pointed-to value are const. The first const (before int) makes the value unchangeable through this pointer. The second const (after the *) makes the pointer itself unchangeable (it cannot point to a different address). Option A only protects the value, not the pointer.