What are volatile variables ? Explain Volatile variables

A variable is declared as volatile if its value can possibly be changed in ways outside either the control or detection of the compiler. For example a variable that is updated by the system clock. Certain optimizations ordinarily performed by a compiler should therefore not be applied to objects the programmer specifies as volatile. The volatile qualifier is used in much the same way as is the const qualifier as an additional modifier to a type.E.g. volatile int count_value; The purpose of defining a variable as volatile is to inform the compiler that the variable can change in ways undetectable by the compiler and hence the compiler should not perform any kind of optimizations on these variables.