What is a key advantage of using a sorted array over an unsorted array?

  • Easier insertion of elements
  • Faster searching
  • Lower memory usage
  • Random access
A key advantage of a sorted array is faster searching using techniques like binary search, which has a logarithmic time complexity.

What is the primary disadvantage of using dynamic memory allocation for arrays in C?

  • Fragmentation
  • Inefficiency
  • Limited Size
  • Slow Access
Dynamic Memory Allocation can lead to memory fragmentation, which can waste memory and affect program performance.

What is the main limitation of using typedef to create an alias for a data type?

  • It adds flexibility to data types
  • It can lead to confusion with multiple typedefs
  • It enforces strong data typing
  • It increases code readability
The main limitation of using typedef to create an alias is that it can lead to confusion when multiple typedefs are used for the same base type.

What type of variable is one that is declared outside any function and is available throughout the program?

  • Constant variable
  • Global variable
  • Local variable
  • Static variable
A global variable is declared outside any function and is accessible throughout the program, making it available for all functions to use.

When reading a file, if the end of the file is reached, the ________ function can be used to check this condition.

  • feof()
  • endoffile()
  • fileend()
  • eofcheck()
The correct option is feof(). This function checks if the end-of-file indicator for a stream has been set, indicating that there are no more characters to read from the file.

In optimizing a recursive algorithm for calculating Fibonacci numbers, what concept can be applied to avoid redundant calculations?

  • Dynamic Typing
  • Functional Programming
  • Memoization
  • Object-Oriented Programming
Memoization is the concept that can be applied to store and reuse intermediate results, avoiding redundant calculations and significantly improving the efficiency of the algorithm.

What is a double pointer in C?

  • It is a pointer that cannot be modified
  • It is a pointer that has two asterisks **
  • It is a pointer that points to floating-point numbers
  • It is a pointer that points to two different memory locations
A double pointer in C is represented with two asterisks ** and is used to point to another pointer. It allows you to modify the pointer it is referencing.

When a file is opened in 'w' mode using fopen, if the file already exists, its contents are ________.

  • Overwritten
  • Appended
  • Preserved
  • Erased
In 'w' mode, if the file already exists, its contents are overwritten, so option a) "Overwritten" is the correct answer.

How does the compiler determine the size of a structure containing bit fields?

  • It uses a fixed size for all structures
  • It sums the sizes of individual bit fields
  • It calculates based on the alignment requirements
  • It uses a predetermined value
The correct option is c) It calculates based on the alignment requirements. When a structure contains bit fields, the compiler determines the size of the structure based on the alignment requirements of the platform. It may add padding bits to ensure proper alignment, which affects the overall size of the structure.

In C, a string is essentially an array of ________ terminated by a null character.

  • characters
  • floats
  • integers
  • pointers
In C, a string is essentially an array of characters terminated by a null character (''). This null character signifies the end of the string and is used to differentiate between the end of one string and the beginning of another in memory.