ProgrammingModerateWipro · Capgemini

Which of these is NOT allowed for a variable declared with the register storage class in C?

  1. A. Initialising it in its declaration
  2. B. Taking its address with &
  3. C. Declaring it inside a nested block
  4. D. Using it as a loop counter

Correct answer: B. Taking its address with &

register is a hint that the variable may live in a CPU register, which has no memory address, so applying & to it is a constraint violation in C (whether or not the compiler uses a register). Everything else an automatic variable can do is allowed.

More C Programming questions

Exams that ask this topic