To split a string into tokens in C, the function ________ is used.

  • split
  • strtok
  • substring
  • splitstr
The correct answer is strtok. strtok is a standard C function used to split a string into tokens. The other options are not valid C functions for this purpose.

In a recursive function, if the base case is not properly defined, it can lead to a ________.

  • Compilation Error
  • Infinite Loop
  • Memory Leak
  • Stack Overflow
When the base case in a recursive function is not properly defined, it can lead to a stack overflow error. A stack overflow occurs when the function calls itself indefinitely, filling up the call stack. This results in a runtime error.

In a program that processes 3D graphics, you need to calculate the distance between points in space. What concept would be useful in efficiently handling the coordinates of these points?

  • Binary search
  • Hash tables
  • Linked lists
  • Pythagorean Theorem
The Pythagorean Theorem is a useful concept for calculating the distance between points in 3D space. It helps efficiently handle the coordinates of these points by providing a straightforward method for distance calculation.

In C, the size of the data type ________ is platform-dependent.

  • char
  • double
  • int
  • long
In C, the size of the data type 'double' is platform-dependent. Different platforms may allocate different memory sizes for 'double' data type.

The function ________ is used to close a file in C.

  • fclose()
  • close()
  • endfile()
  • fileclose()
The correct option is a) fclose(). This function in C is used to close the file associated with the specified file pointer.

In C, what is the effect of using pointers as function parameters with regards to pass by value and pass by reference?

  • Pointers can only be used in pass by value scenarios.
  • Pointers enable pass by reference.
  • Pointers enable pass by value.
  • Pointers have no impact on pass by value or pass by reference.
Using pointers as function parameters in C enables pass by reference. When a pointer to a variable is passed to a function, changes made to the variable within the function are reflected outside the function, similar to pass by reference.

The use of inline functions can potentially lead to faster execution time but may also increase the ________ of the binary.

  • Complexity
  • Efficiency
  • Size
  • Speed
Inline functions can optimize execution time by eliminating the function call overhead. However, they may increase binary complexity due to code expansion, making the binary larger.

When a pointer is incremented, it moves to the memory address of the next element based on the ________ of the data type it points to.

  • Color
  • Name
  • Shape
  • Size
Pointer incrementation in C is determined by the size (in bytes) of the data type it points to.

You're optimizing a program for memory usage. What considerations would you take into account when deciding between using character arrays and string literals?

  • Character arrays consume less memory than string literals, making them a better choice for memory optimization.
  • Character arrays provide better performance due to reduced memory overhead.
  • String literals are less efficient in terms of memory usage compared to character arrays.
  • String literals are more memory-efficient, as they share storage and avoid duplicating string data.
When optimizing a program for memory usage, you would consider using character arrays over string literals because character arrays generally consume less memory. String literals can lead to duplicate storage, whereas character arrays allow more control over memory usage.

What happens when you perform pointer arithmetic on a pointer to a data type other than 'char'?

  • It generates a compilation error
  • It increments the pointer by one byte
  • It results in undefined behavior
  • It returns the size of the data type in bytes
When you perform pointer arithmetic on a pointer to a data type other than 'char,' it results in undefined behavior. This is because the pointer arithmetic depends on the size of the data type, and it may lead to accessing memory incorrectly.