How does the strtok() function work in C?

  • It calculates the length of a string
  • It converts a string to uppercase
  • It performs a binary search
  • It splits a string into multiple substrings based on a delimiter
The strtok() function in C is used to split a string into multiple substrings based on a specified delimiter. It maintains state between calls, making it useful for tokenizing strings.

What function can be used to find the current position of the file pointer in a file?

  • fseek()
  • readPosition()
  • getCurrentPointer()
  • filePosition()
The correct function to find the current position of the file pointer in a file is 'fseek()'. It allows you to set the file position indicator to a specific location in the file and returns the current position. The other options are not valid functions for this purpose.

You are developing a program to manage the seating arrangement in a movie theater with rows and columns. How would you represent the seats using arrays?

  • 1D Array
  • 2D Array
  • Linked List
  • Queue (FIFO)
Seats in a theater can be efficiently represented using a 2D array, with rows and columns, making it easy to access and manage each seat's status.

How does the 'return' statement affect the flow of control within a loop?

  • The 'return' statement exits the loop, returning control to the calling function or method.
  • The 'return' statement has no impact on the flow of control within a loop.
  • The 'return' statement skips the next iteration of the loop.
  • The 'return' statement terminates the entire program when used within a loop.
The 'return' statement is used to exit a function or method prematurely and return a value. When a 'return' statement is encountered within a loop, it immediately exits the loop and returns control to the calling function or method. This can be useful for ending a loop under certain conditions or returning a value from the loop.

When declaring a pointer in C, which symbol is used to denote that a variable is a pointer?

  • #
  • $
  • &
  • *
In C, the asterisk (*) symbol is used to declare a pointer variable. For example, int *ptr declares a pointer to an integer.

When you increment a pointer in C, it advances the pointer by the size of the type to which it points, which is known as ________.

  • Looping
  • Memory allocation
  • Pointer arithmetic
  • Typecasting
When you increment a pointer in C, it advances the pointer by the size of the type to which it points, and this operation is known as pointer arithmetic. It allows you to navigate through data structures in memory.

What is the significance of using pointers when working with structures in C?

  • Pointers allow dynamic memory allocation.
  • Pointers enable structures to be passed to functions efficiently.
  • Pointers prevent data corruption in structures.
  • Pointers simplify access to structure members.
Using pointers when working with structures in C is essential because they enable efficient access to structure members when they are passed to functions. This allows you to manipulate data inside structures without having to create copies of the entire structure.

How can a structure be passed to a function in C?

  • By creating a copy inside the function
  • By reference
  • By using global variables
  • By value
A structure can be passed to a function in C by reference (using a pointer or passing the address of the structure). This allows the function to modify the original structure's contents.

What is a pointer in C programming?

  • A control structure in C
  • A data type used for characters
  • A function that returns values
  • A variable that stores addresses
A pointer in C is a variable that stores the memory address of another variable. It's often used for dynamic memory allocation and accessing data indirectly.

What is the role of the 'continue' statement in a loop?

  • It exits the program.
  • It restarts the loop from the beginning.
  • It skips the current iteration and continues with the next.
  • It terminates the loop.
The 'continue' statement is used in loops to skip the current iteration and move to the next iteration. It does not terminate the loop but helps to skip certain iterations.