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.

What is the significance of using pointers in function arguments?

  • It allows passing arguments by reference
  • It enforces strong typing
  • It reduces code readability
  • It simplifies function declarations
Using pointers in function arguments allows passing arguments by reference, meaning the function can modify the original data, not just a copy. This is valuable when you want a function to modify variables from the caller's scope.

In a 'switch' statement, the ________ keyword is used to specify the code to execute if none of the cases match.

  • Break
  • Continue
  • Default
  • Exit
The correct option is (c) Default. In a 'switch' statement in C, the 'default' keyword is used to specify the code to execute if none of the cases match the provided value. It acts as a fallback option.

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.