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.

In a program that processes large datasets, you notice that reading the data from a file is a performance bottleneck. Which file handling functions could help improve the performance?

  • fread() and fwrite()
  • fseek() and ftell()
  • fprintf() and fscanf()
  • fgetc() and fputc()
To improve performance when dealing with large datasets, using fread() and fwrite() for bulk reading and writing of data would be beneficial. The other options involve more granular or formatted I/O operations.

What is the difference between #include "filename" and #include in C?

  • #include "filename" is for standard library files.
  • #include "filename" is for user-defined files.
  • #include is for user-defined files.
  • They are interchangeable and have no difference.
In C, #include "filename" is used for user-defined header files, and #include is used for standard library header files.

Which searching algorithm is typically the most straightforward to implement?

  • Binary search
  • Hash table
  • Jump search
  • Linear search
Linear search is the most straightforward searching algorithm as it involves a simple step-by-step comparison of elements in the array.

What is the default starting value of an enumeration in C?

  • 0
  • 1
  • The value of the first enumeration constant
  • Unspecified
In C, if no initial value is provided for the first enumeration constant, it starts with 0. Subsequent constants increment by 1.

In C, what is the difference in memory allocation between character arrays and string literals?

  • Character arrays are automatically null-terminated, while string literals are not.
  • Character arrays are stored in read-write memory, while string literals are stored in read-only memory.
  • Character arrays cannot be used as function arguments, while string literals can.
  • String literals are stored in read-write memory, while character arrays are stored in read-only memory.
Character arrays in C are typically stored in read-write memory, allowing you to modify their contents. In contrast, string literals are stored in read-only memory, making them immutable. This difference in memory allocation is essential for understanding how to work with strings in C.