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.

Which looping construct is best suited when the number of iterations is known beforehand?

  • do-while
  • for
  • switch
  • while
The 'for' loop is commonly used when the number of iterations is known beforehand, as it allows you to specify the initialization, condition, and iteration steps in a compact manner.

The keyword ________ is used to define a structure in C.

  • allocate
  • define
  • struct
  • typedef
In C, the "struct" keyword is used to define a structure. Structures are used to group related data members under a single name.

The function ________ is used to move the file pointer to a specific position in the file.

  • file_seek()
  • fseek()
  • move_pointer()
  • position_file()
In file handling, fseek() is employed to move the file pointer to a specified position within the file. This is crucial for navigating and accessing specific parts of a file during read or write operations.

You're developing a program to calculate the area of a circle. What data type would be most suitable to store the radius, considering it can be a fractional value?

  • char
  • double
  • float
  • int
To store the radius of a circle with fractional values, the most suitable data type in C is 'double' as it offers high precision for such calculations.

What is the purpose of using random access in file handling?

  • To access files in a random order.
  • To create files with random names.
  • To generate random numbers for file operations.
  • To perform direct read/write operations at any position within the file.
The purpose of using random access in file handling is to perform direct read and write operations at any position within the file. Random access allows you to jump to a specific location in a file and read or write data without having to sequentially process the entire file. It's especially useful for large files or databases.

In a scientific computation program, you need to represent a matrix of real numbers. What kind of array would be suitable for this purpose?

  • 1D Array
  • 2D Array
  • Binary Tree
  • Dynamic Array (ArrayList)
A 2D array is suitable for representing a matrix of real numbers as it offers a grid-like structure to store rows and columns of values.

In C, what is the result of the expression (5 & 3)?

  • 0
  • 1
  • 3
  • 5
In C, the '&' operator is the bitwise AND operator. When you perform (5 & 3), it bitwise ANDs the binary representation of 5 (0101) and 3 (0011). The result is 0001, which is 1 in decimal.

What is the behavior of malloc when the size requested is zero?

  • It goes into an infinite loop
  • It returns a null pointer (NULL)
  • It returns a pointer to a zero-sized memory block
  • It returns an error
When you request zero bytes of memory using malloc, it returns a null pointer (NULL) rather than allocating a zero-sized memory block. This is useful for special cases when you need a pointer that doesn't point to any memory.