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.

A function in C returns a value to the calling function using the ________ keyword.

  • output
  • result
  • return
  • value
In C, the "return" keyword is used to return a value to the calling function. It specifies the value that the function will return.

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.

In C++, what is function overloading?

  • Creating new functions with unique names for each
  • Using different names for the same function with the same parameters
  • Using the same name for a single function with different parameters
  • Using the same name for different functions with different parameters
In C++, function overloading refers to using the same function name for different functions with different parameter lists. This allows you to perform similar operations with different data types.

What does a nested structure in C allow you to do?

  • Create a structure inside another structure
  • Define a function inside a structure
  • Define a structure with no members
  • Nest loops within a structure
In C programming, a nested structure allows you to create a structure inside another structure. This can be useful when you want to represent complex data structures, as it lets you organize related data even further, creating a hierarchical structure.

In C, if you want to ensure that all the data written to a file is physically stored, you can use the ______ function.

  • fwrite()
  • fflush()
  • fseek()
  • fsync()
The correct option is b) fflush(). This function flushes the output buffer, ensuring that all data is physically stored in the file.

Why would a developer use pointers to structures instead of using structures directly?

  • To add complexity to the code
  • To improve program performance
  • To save memory
  • To simplify the code
Developers use pointers to structures to improve program performance. When you use pointers, you can manipulate data more efficiently and avoid creating redundant copies of structures, leading to better memory and performance optimization. It simplifies code by allowing you to pass structures by reference and make changes directly to the original data. However, it can add complexity to the code, so careful usage is essential.