What might be a reason to use bit fields when designing a system with strict memory constraints?

  • They allow more precise control over memory usage
  • They improve code performance
  • They offer greater data integrity
  • They simplify code logic
Bit fields can be useful in systems with strict memory constraints because they allow more precise control over memory usage by packing data in smaller units.

What potential problem might occur when using fseek and ftell with large binary files?

  • Data corruption
  • Inaccurate file positioning
  • Memory overflow
  • Performance degradation
When working with large binary files, using fseek and ftell may result in inaccurate file positioning. This is because these functions use a single long integer to represent the file position, which may not be sufficient to handle the large offsets required for large files. This can lead to errors in file positioning and unintended behavior in your code.

In C, what happens if you attempt to open a file for reading using fopen() but the file does not exist?

  • fopen() returns NULL, indicating that the file does not exist.
  • fopen() raises an exception.
  • fopen() creates a new file with the specified name.
  • fopen() prompts the user to enter the correct file name.
The correct option is "fopen() returns NULL, indicating that the file does not exist." If the file does not exist or cannot be opened for some reason, fopen() returns a NULL pointer, indicating an error in opening the file.

What function is used to open a binary file for both reading and writing in C?

  • fopen()
  • open()
  • openfile()
  • readfile()
In C, the fopen() function is used to open a binary file for both reading and writing. It returns a file pointer, which is essential for performing file operations.

Pointers can lead to ________ if not managed correctly in a C program.

  • Compilation errors
  • Memory leaks
  • Segmentation faults
  • Stack overflows
Pointers in C can cause segmentation faults when not handled properly. A segmentation fault occurs when a program tries to access memory that it's not allowed to access.

Function pointers in C can be passed as arguments to functions, thereby providing a degree of ________.

  • Abstraction
  • Encapsulation
  • Flexibility
  • Polymorphism
In C, function pointers enable polymorphism by allowing you to call different functions dynamically. This provides flexibility in your code.

What term is used to describe the process of calling a function within itself?

  • Casting
  • Looping
  • Recursion
  • Structuring
The process of calling a function within itself is known as "recursion." It allows for solving problems that can be broken down into smaller, similar subproblems.

The size of a structure in memory is determined by the ________ of its members.

  • maximum
  • minimum
  • sum
  • total
The size of a structure in memory is determined by the total size of its members. This includes the size of all individual data members within the structure.

Using the ________ keyword before a function suggests to the compiler that the function should be expanded at the point where it is called.

  • Dynamic
  • Inline
  • Static
  • Virtual
The "inline" keyword suggests to the compiler that the function should be expanded at the call site for performance optimization.

What is the significance of the SEEK_SET, SEEK_CUR, and SEEK_END constants in file handling?

  • File attributes
  • File permissions
  • File positioning
  • File type
In file handling, the SEEK_SET, SEEK_CUR, and SEEK_END constants are used to define the reference point for file positioning. SEEK_SET sets the file position from the beginning of the file, SEEK_CUR sets it relative to the current position, and SEEK_END sets it relative to the end of the file. These constants are crucial for accurate file positioning and seeking within files.