|
C Interview Questions with Answers posted on August 06, 2008 at 13:10
PM by Amit Satpute
Question - Define the scope of static variables.
Answer
The scope of a static variable is local to the block in which the variable is
defined. However, the value of the static variable persists between two
function calls.
Question - What are volatile variables?
Answer
Volatile variables get special attention from the compiler. A variable declared
with the volatile keyword may be modified externally from the declaring
function.
If the keyword volatile is not used, the compiler optimization algorithms might
consider this to be a case of infinite loop. Declaring a variable volatile
indicates to a compiler that there could be external processes that could
possibly alter the value of that variable.
e.g.:
A variable that might be concurrently modified by multiple threads may be
declared volatile. Variables declared to be volatile will not be optimized by
the compiler. Compiler must assume that their values can change at any time.
However, operations on a volatile variable are still not guaranteed to be
atomic.
Question - Explain the meaning of "Segmentation violation".
Answer
A segmentation violation usually indicates an attempt to access memory
which doesn't even exist.
Question - What is "Bus error"?
Answer
A bus error indicates an attempt to access memory in an illegal
way,perhaps due to an unaligned pointer.
|