What is the result of comparing two strings using the '==' operator in C?

  • It compares the ASCII values of the first characters
  • It compares the content of the strings
  • It compares the length of the strings
  • It compares the memory addresses of the strings
In C, the '==' operator compares the memory addresses of the strings, not their content.

In a program that processes large amounts of data, what strategy can be used to optimize the performance of loops?

  • Loop branching optimization
  • Loop indexing optimization
  • Loop parallelization
  • Loop unrolling
To optimize the performance of loops when processing large data, 'loop unrolling' can be used. Loop unrolling reduces loop overhead and can improve data processing speed.

The fread function in C is used to read data from a file and stores the data in the ________.

  • Buffer
  • Memory
  • Stack
  • Registers
The fread function in C reads data from a file and stores it in memory, making option b) "Memory" the correct answer.

In C, the ________ function is used to copy a specified number of characters from one string to another.

  • memcpy()
  • strcpy()
  • strncat()
  • strncpy()
In C, the strncpy() function is used to copy a specified number of characters from one string to another. Unlike strcpy(), it allows you to specify the maximum number of characters to copy, which helps prevent buffer overflows and enhances program security.

In a graphics rendering engine, you need to apply different transformations (e.g., rotate, scale, translate) to objects. How can function pointers be used to simplify the implementation?

  • Define a function pointer for each transformation type
  • Use if-else statements to select transformations
  • Use global variables to store transformation functions
  • Implement each transformation directly in the code
Option A is the correct answer. By defining a function pointer for each transformation type, you can easily switch between different transformations without altering the engine's core logic. Options B, C, and D are less flexible and efficient. Option A simplifies the code.

The ______ function in C can be used to change the position of the file pointer in a stream.

  • fmove()
  • fseek()
  • fileptr()
  • fposition()
The correct option is b) fseek(). This function is used to set the file position indicator for the specified stream, allowing you to move the file pointer to a specific location.

You are working on a program that simulates a chessboard. How would you represent the chessboard using arrays?

  • 1D Array
  • 2D Array
  • Hash Table
  • Linked List
A chessboard is best represented using a 2D array because it provides a grid structure, allowing easy indexing for each square.

How do you declare a pointer variable in C?

  • Using the % operator
  • Using the & operator
  • Using the * operator
  • Using the -> operator
In C, you declare a pointer variable using the * operator. For example, int *ptr; declares a pointer to an integer.

How does the 'extern' keyword affect the scope and lifetime of a variable in C?

  • It doesn't affect the scope or lifetime of a variable.
  • It extends the scope and lifetime of a variable.
  • It extends the scope but reduces the lifetime of a variable.
  • It reduces the scope but extends the lifetime of a variable.
In C, the 'extern' keyword extends the scope of a variable but reduces its lifetime. It allows a variable declared outside a function to be used within that function, but the variable's lifetime remains outside the function.

How are strings typically terminated in C?

  • With a comma
  • With a newline character
  • With a null character ( '' )
  • With a space character
Strings in C are typically terminated with a null character ('') to indicate the end of the string.