In C, the volatile keyword is used to indicate that a variable’s value can be changed unexpectedly, outside the program’s control. This prevents the compiler from optimizing or caching the value of that variable. It is commonly used for variables that interact with hardware, memory-mapped registers, or are modified by interrupt service routines. Without volatile, the compiler might optimize out necessary reads or writes, leading to incorrect behavior. For example, a variable shared between the main program and an interrupt handler needs to be declared volatile to ensure the program always reads the current value.