Home / Questions / What is the difference between auto variable and register variable in C?
Explanatory Question

What is the difference between auto variable and register variable in C?

👁 2,505 Views
📘 Detailed Answer
🕒 Easy to Read
Read the answer carefully and go through the related questions on the right side to improve your understanding of this topic.

Answer with Explanation

Storage class of all variables are auto by default unless we specify a variable is register or static or extern in C program.

  • Both auto variable and register variable are local variables. Register variables are stored in register memory. Whereas, auto variables are stored in main CPU memory.
  • Register variables will be accessed very faster than the normal/auto variables since they are stored in register memory rather than main memory.
  • But, only limited variables can be used as register since register size is very low. (16 bits, 32 bits or 64 bits)