Govt. Exams
Entrance Exams
volatile tells compiler not to optimize variable accesses and to fetch fresh value from memory, useful for hardware registers and shared memory, but doesn't guarantee thread-safety without synchronization.
float x = 0.1 + 0.2;
if(x == 0.3) printf("Equal"); else printf("Not Equal");
Due to floating-point precision limitations, 0.1 + 0.2 does not exactly equal 0.3 in binary representation. Direct comparison with == fails.
p is a pointer variable, so sizeof(p) returns the size of the pointer itself (4 bytes on 32-bit, 8 bytes on 64-bit systems), not the array.
The 'restrict' qualifier tells the compiler that a pointer is the only way to access that object, enabling optimizations.
Register is a hint only; compiler may ignore it. You cannot use & operator on register variables.
Both 'const int * const p' and 'int const * const p' are equivalent and declare constant pointer to constant integer.
Modifying variable x twice without intervening sequence point causes undefined behavior.
'const int *p' - pointer can change but value cannot. 'int * const p' - value can change but pointer cannot.
restrict (C99) informs the compiler that a pointer is the sole accessor to the object, enabling optimization. It doesn't prevent modification.
The '*' applies only to the immediately following variable. So 'int *p' declares p as pointer to int, and 'q' is just an int.