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 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.

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.