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.

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.

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.

Enumerations provide a way to assign ________ to a set of named constants.

  • data
  • functions
  • objects
  • values
Enumerations allow you to assign integer values to a set of named constants, making your code more readable and maintainable by giving meaningful names to values.

What is the return type of the strlen function in C?

  • char
  • int
  • size_t
  • void
The strlen function in C returns a value of type size_t, which represents the size or length of the string. Using size_t is more appropriate as it can handle large string lengths and is an unsigned integer type.

Pointer arithmetic in C is based on ________, which means that the pointer is incremented or decremented by the size of the data type it points to.

  • address arithmetic
  • object arithmetic
  • relative arithmetic
  • value arithmetic
Pointer arithmetic in C is based on address arithmetic, meaning that when you increment or decrement a pointer, it moves by the size of the data type it points to. This is a fundamental concept in C programming and is crucial for memory manipulation.

What function is used in C to allocate a block of memory for an array of elements, initialize them to zero, and then return a pointer to the memory?

  • alloc
  • calloc
  • malloc
  • realloc
The calloc function in C is used to allocate a block of memory for an array of elements, initializes them to zero, and returns a pointer to the memory. It is especially useful for dynamic memory allocation.

When working with binary files in C, what is the significance of the 'b' character in the mode string?

  • It denotes the file is binary, and data is stored as a series of 0s and 1s.
  • It indicates the file is a backup copy.
  • It represents the file is a text file.
  • It specifies the file is in compressed format.
In C, the 'b' character in the mode string indicates that the file is opened in binary mode. In this mode, data is read or written in its raw binary form, without any character encoding or translation. This is essential when working with binary files like images or executable files.

How does C++ resolve calls to overloaded functions?

  • Overloaded function resolution is based on the function name
  • Overloaded function resolution is based on the number and types of parameters
  • Overloaded function resolution is based on the return type
  • Overloaded function resolution is random
In C++, when there are multiple overloaded functions with the same name, the compiler resolves the calls based on the number and types of parameters provided in the function call. This process is known as function overloading, and it allows C++ to choose the most appropriate function to call based on the arguments provided.

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.

The function ________ is used to read formatted input from the standard input.

  • print
  • scanf
  • printf
  • cout
The "scanf" function is used in C and C++ to read formatted input from the standard input (usually the keyboard). It allows you to input and store values in variables while specifying the format in which data should be entered. Options like "print," "printf," and "cout" are used for output, not input.

What is the effect of not specifying the size of the array when initializing it with a list of values?

  • Compilation error
  • The array is initialized with a default size of 10
  • The array size is automatically set based on the number of values
  • Undefined behavior
When initializing an array with a list of values in C without specifying the size, the array size is automatically set based on the number of values. It is a convenient feature in C known as array initialization without a size specification.