The sample code above releases memory from a linked list. Which of the choices below accurately describes how it will work? Choice 1
It will work correctly since the for loop covers the entire list. Choice 2
It may fail since each node "nPtr" is freed before its next address can be accessed. Choice 3
In the for loop, the assignment "nPtr=nPtr->next" should be changed to "nPtr=nPtr.next". Choice 4
This is invalid syntax for freeing memory. Choice 5
The loop will never end.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

The function array_dup(), defined above, contains an error. Which one of the following correctly analyzes it? Choice 1
If the arguments to memcpy() refer to overlapping regions, the destination buffer will be subject to memory corruption. Choice 2
array_dup() declares its first parameter to be a pointer, when the actual argument will be an array. Choice 3
The memory obtained from alloca() is not valid in the context of the caller. Moreover, alloca() is nonstandard. Choice 4
size_t is not a Standard C defined type, and may not be known to the compiler. Choice 5
The definition of array_dup() is unusual. Functions cannot be defined using this syntax.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

/*question number 20*/
int var1;
If a variable is declared as above, can it be accessed from another file? Choice 1
Yes; it can be referenced. Choice 2
No; it should be declared as a static variable. Choice 3
No; it should be declared using the global keyword.[Ans] Choice 4
Yes; it can be referenced through the publish specifier. Choice 5
Yes; it can be referenced through the extern specifier.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

/*question number 34*/
All of the following choices represent syntactically correct function definitions. Which one of the following represents a semantically legal function definition in Standard C? Choice 1

/*question number 36*/
Which one of the following is a true statement about pointers? Choice 1
Pointer arithmetic is permitted on pointers of any type. Choice 2
A pointer of type void * can be used to directly examine or modify an object of any type. Choice 3
Standard C mandates a minimum of four levels of indirection accessible through a pointer. Choice 4
A C program knows the types of its pointers and indirectly referenced data items at runtime. Choice 5
Pointers may be used to simulate call-by-reference.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

char * buf = "Hello world!";
In terms of code generation, how do the two definitions of buf, both presented above, differ? Choice 1
The first definition certainly allows the contents of buf to be safely modified at runtime; the second definition does not. Choice 2
The first definition is not suitable for usage as an argument to a function call; the second definition is. Choice 3
The first definition is not legal because it does not indicate the size of the array to be allocated; the second definition is legal. Choice 4
They do not differ -- they are functionally equivalent. [Ans]Choice 5
The first definition does not allocate enough space for a terminating NUL-character, nor does it append one; the second definition does.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

/*question number 58*/
int a [8] = { 0, 1, 2, 3 };
The definition of a above explicitly initializes its first four elements. Which one of the following describes how the compiler treats the remaining four elements? Choice 1
Standard C defines this particular behavior as implementation-dependent. The compiler writer has the freedom to decide how the remaining elements will be handled. Choice 2
The remaining elements are initialized to zero(0).[Ans] Choice 3
It is illegal to initialize only a portion of the array. Either the entire array must be initialized, or no part of it may be initialized. Choice 4
As with an enum, the compiler assigns values to the remaining elements by counting up from the last explicitly initialized element. The final four elements will acquire the values 4, 5, 6, and 7, respectively. Choice 5
They are left in an uninitialized state; their values cannot be relied upon.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

/*question number 59*/
Which one of the following is a true statement about pointers? Choice 1
They are always 32-bit values. Choice 2
For efficiency, pointer values are always stored in machine registers. Choice 3
With the exception of generic pointers, similarly typed pointers may be subtracted from each other. Choice 4
A pointer to one type may not be cast to a pointer to any other type. Choice 5
With the exception of generic pointers, similarly typed pointers may be added to each other.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Consider the function increment_ints(), defined above. Despite its significant inline commentary, it contains an error. Which one of the following correctly assesses it? Choice 1
*p++ causes p to be incremented before the dereference is performed, because both operators have equal precedence and are right associative. Choice 2
An array is a nonmodifiable lvalue, so p cannot be incremented directly. A navigation pointer should be used in conjunction with p. Choice 3
*p++ causes p to be incremented before the dereference is performed, because the autoincrement operator has higher precedence than the indirection operator. Choice 4
The condition of a while loop must be a Boolean expression. The condition should be n != 0. Choice 5
An array cannot be initialized to a variable size. The subscript n should be removed from the definition of the parameter p.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

The function read_long_string(), defined above, contains an error that may be particularly visible under heavy stress. Which one of the following describes it? Choice 1
The write to *buf is blocked by the const qualifications applied to its type. Choice 2
If the null pointer for char is not zero-valued on the host machine, the implicit comparisons to zero (0) may introduce undesired behavior. Moreover, even if successful, it introduces machine-dependent behavior and harms portability. Choice 3
The symbol stdin may not be defined on some ANCI C compliant systems. Choice 4
The else causes fwd to contain an errant address. Choice 5
If the call to realloc() fails during any iteration but the first, all memory previously allocated by the loop is leaked.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

/*question number 75*/
Which one of the following is true for identifiers that begin with an underscore? Choice 1
They are generally treated differently by preprocessors and compilers from other identifiers. Choice 2
They are case-insensitive. Choice 3
They are reserved for usage by standards committees, system implementers, and compiler engineers. Choice 4
Applications programmers are encouraged to employ them in their own code in order to mark certain symbols for internal usage. Choice 5
They are deprecated by Standard C and are permitted only for backward compatibility with older C libraries.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

The function crash(), defined above, triggers a fault in the memory management hardware for many architectures. Which one of the following explains why "got here" may NOT be printed before the crash? Choice 1
The C standard says that dereferencing a null pointer causes undefined behavior. This may explain why printf() apparently fails. Choice 2
If the standard output stream is buffered, the library buffers may not be flushed before the crash occurs. Choice 3
printf() always buffers output until a newline character appears in the buffer. Since no newline was present in the format string, nothing is printed. Choice 4
There is insufficient information to determine why the output fails to appear. A broader context is required. Choice 5
printf() expects more than a single argument. Since only one argument is given, the crash may actually occur inside printf(), which explains why the string is not printed. puts() should be used instead.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

The function debug(), defined above, contains an error. Which one of the following describes it? Choice 1
The ellipsis is a throwback from K&R C. In accordance with Standard C, the declaration of args should be moved into the parameter list, and the K&R C macro va_arg() should be deleted from the code. Choice 2
vfprintf() does not conform to ISO 9899: 1990, and may not be portable. Choice 3
Library routines that accept argument lists cause a fault on receipt of an empty list. The argument list must be validated with va_null() before invoking vfprintf(). Choice 4
The argument list args has been improperly initialized. Choice 5
Variadic functions are discontinued by Standard C; they are legacy constructs from K&R C, and no longer compile under modern compilers.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

The function sum_array(), defined above, contains an error. Which one of the following accurately describes it? Choice 1
The range of the loop does not match the bounds of the array d. Choice 2
The loop processes the incorrect number of elements. Choice 3
total is initialized with an integer literal. The two are not compatible in an assignment. Choice 4
The code above fails to compile if there are no registers available for i. Choice 5
The formal parameter d should be declared as double * d to allow dynamically allocated arrays as arguments.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

The function above has a flaw that may result in a serious error during some invocations. Which one of the following describes the deficiency illustrated above? Choice 1
For some values of n, the environment will almost certainly exhaust its stack space before the calculation completes.
[Ans] Choice 2
An error in the algorithm causes unbounded recursion for all values of n. Choice 3
A break statement should be inserted after each case. Fall-through is not desirable here. Choice 4
The fibonacci() function includes calls to itself. This is not directly supported by Standard C due to its unreliability. Choice 5
Since the default case is given first, it will be executed before any case matching n.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -