Which statement is true regarding the difference between inline functions and macros in C?

  • Inline functions are always faster
  • Inline functions can access local variables
  • Macros are always inlined
  • Macros are type-safe
Inline functions in C can access local variables and provide better type safety compared to macros. Macros are simple text replacements, which may lead to unexpected behavior.

In an application that writes user data to a text file, what precaution should be taken to avoid data corruption or loss?

  • Delay disk writes to optimize performance.
  • Ensure the application flushes the buffer after each write.
  • Overwrite existing data without checking for errors.
  • Use a non-atomic write operation.
To avoid data corruption or loss, it's crucial to flush the buffer after each write operation to ensure data is written to the file immediately.

What is the term used to describe the number of indices needed to select an element in a multidimensional array?

  • Array Depth
  • Dimensionality
  • Index Complexity
  • Selection Rank
The term used to describe the number of indices needed to select an element in a multidimensional array is dimensionality. In a multidimensional array, each dimension requires a separate index to access an element.

The function ________ in C changes the size of the memory block pointed to by a given pointer.

  • realloc()
  • free()
  • malloc()
  • calloc()
The correct option is 'realloc()'. The realloc() function is used to change the size of a previously allocated memory block, making it suitable for resizing dynamic arrays.

You're writing a program that needs to efficiently calculate the power of 2 for a given exponent. Which operator would be most efficient to use?

  • * (Multiplication)
  • ** (Exponentiation)
  • << (Left Shift)
  • ^ (Bitwise XOR)
The correct answer is C) ** (Exponentiation). To efficiently calculate the power of 2 for a given exponent, you should use the exponentiation operator (**).

What will happen if the condition in a 'while' loop is initially false?

  • It will enter the loop and execute it once.
  • It will enter the loop and run indefinitely.
  • It will result in a compile-time error.
  • It won't enter the loop.
When the condition in a 'while' loop is initially false, the loop will not execute, and the program will proceed to the next statement.

How does C handle array indices that are out of bounds?

  • C dynamically resizes the array
  • C ignores out-of-bounds indices
  • C throws a runtime error
  • C wraps around to the beginning of the array
In C, when array indices are out of bounds, the behavior is undefined. C does not perform any bounds checking, and it's the programmer's responsibility to ensure indices are within bounds to avoid unexpected results.

The ________ keyword in C is used to give a reference to a variable that is already defined in some other scope.

  • auto
  • extern
  • register
  • static
In C, the extern keyword is used to give a reference to a variable that is already defined in some other scope. It is often used to access global variables that are defined outside the current function or block. This keyword allows you to use variables across different scopes.

You are developing an interactive application that continuously accepts user input until the user decides to exit. Which loop construct would be most appropriate for this scenario?

  • do-while loop
  • for loop
  • switch statement
  • while loop
The most appropriate loop construct for an interactive application that accepts user input until the user decides to exit is a 'while loop.' It allows continuous input acceptance while checking an exit condition.

Function pointers in C can be stored in an array, creating a(n) ________ of function pointers.

  • Array of Function Pointers
  • Collection
  • Group
  • List
Function pointers in C can be stored in an array, creating an array of function pointers, which can be used for dynamic function calls.