You are tasked with implementing a plugin system in a software application where different plugins can be loaded and executed at runtime. How can function pointers be utilized in this scenario?

  • They allow plugins to access the internet.
  • They allow plugins to share global variables.
  • They enable plugins to call functions in the application.
  • They help manage memory allocation for plugins.
Function pointers are used to provide a mechanism for plugins to call specific functions within the application at runtime, enabling extensibility and customization.

How does function overloading in C++ enhance code readability and maintainability?

  • It allows functions to have the same name and return type.
  • It allows multiple functions with the same name but different parameter types.
  • It is not related to code maintainability.
  • It reduces code readability by introducing ambiguity.
Function overloading in C++ allows you to define multiple functions with the same name but different parameter types, making the code more readable and expressive. It enables you to use intuitive function names for various versions of a task.

When dealing with large datasets, what is the advantage of using 'long long int' over 'int'?

  • Better precision
  • Higher range
  • No advantage
  • Smaller memory usage
When dealing with large datasets, using 'long long int' provides a higher range of values that can be represented, which is useful for large data. It comes at the cost of increased memory usage.

When using pointers to structures, the ________ operator is used to access the members of the structure.

  • Arrow (->)
  • Asterisk (*)
  • Comma (,)
  • Period (.)
Pointers to structures are used with the arrow operator (->) to access structure members. The arrow operator is used to dereference the pointer and access the member directly.

String literals in C are stored in ________ memory segment.

  • Code
  • Data
  • Heap
  • Stack
In C, string literals are stored in the data memory segment. This segment contains constants, such as global and static variables.

The function ________ can be used to determine the size of a file in C.

  • size()
  • filesize()
  • file_size()
  • fsize()
The correct option is fsize(). The fsize() function is commonly used in C to determine the size of a file by positioning the file pointer at the end and then retrieving the position.

The function ________ is used in C to allocate memory for an array of specified size dynamically.

  • free
  • malloc
  • printf
  • scanf
In C, the function 'malloc' is used to allocate memory for an array of specified size dynamically. 'malloc' stands for memory allocation.

What is the default value of elements in an array declared as int arr[5]; in C?

  • 0
  • 5
  • Random integers
  • Undefined
In C, when you declare an array without initializing it, all its elements are set to 0 by default. Hence, the correct answer is 0.

How is data stored in a two-dimensional array in memory?

  • In reverse order
  • Randomly, without any order
  • Sequentially, row by row
  • Vertically, column by column
In a two-dimensional array, data is stored sequentially, row by row. Each row is contiguous in memory, and elements are stored in the order they appear in the row.

What is the primary use of the fseek function in file handling?

  • Closing a file
  • Moving the cursor to the end of a file
  • Moving the file cursor to a specific position
  • Setting the file's permissions
The primary use of the fseek() function is to move the file cursor to a specific position within the file. This allows you to read or write data at a specific location in the file.