When a function receives a pointer as an argument, it can modify the ________ that the pointer points to.
- memory
- pointer
- value
- variable
When a function receives a pointer as an argument in C, it can modify the variable that the pointer points to because it operates directly on the memory location pointed to by the pointer.
What is the result of adding an integer to a pointer?
- It causes a compilation error.
- It increments the integer.
- It increments the pointer.
- It multiplies the integer.
Adding an integer to a pointer in C increments the pointer by the product of the integer and the size of the data type pointed to. It does not increment the integer itself. If the result is outside the valid memory range, it can lead to undefined behavior.
Using pointers to structures can lead to more efficient use of ________.
- Data
- Memory
- Storage
- Variables
Pointers to structures in C can lead to more efficient use of storage, as they enable you to manipulate and access the structure's data directly in memory, reducing the need for copying data.
The ________ statement in C is used to execute a block of code only when a specific condition is true.
- For Loop
- While Loop
- If Statement
- Do-While Loop
The correct option is (c) If Statement. In C, the 'if' statement is used to execute a block of code only when a specific condition is true. If the condition is false, the code inside the 'if' block is skipped.
When an array is passed to a function, it is actually passing the ________ of the first element.
- Address
- Copy
- Reference
- Value
When you pass an array to a function in C, you are actually passing the address (pointer) of the first element of the array. This allows the function to access and modify the original array.
You are working on an application that requires fast data retrieval times. What method of file access would be most suitable?
- Direct File Access
- Indexed File Access
- Random Access
- Sequential File Access
For fast data retrieval times, Random Access is the most suitable method. Unlike Sequential File Access, which reads data sequentially, and Indexed File Access, which uses an index to locate data, Random Access allows direct access to any part of the file. This is crucial for applications where quick retrieval of specific data is essential, such as databases and real-time systems.
You are developing a contact management system where each contact can have multiple addresses (home, work, etc.). How can you efficiently represent this information using structures?
- By creating a separate database for addresses
- By using an array for each contact
- By using separate variables for each address
- By utilizing a structure to hold multiple addresses within a contact structure
To efficiently represent multiple addresses for each contact, you can use a structure to hold multiple addresses within a contact structure. This approach ensures that each contact can have different types of addresses, such as home and work, making it a practical way to manage contact information.
How can you determine if you have reached the end of a file while reading it in C?
- Check if the file size is zero.
- Count the number of lines in the file.
- Examine the file's creation date.
- Use the feof function to check for end-of-file status.
You can determine if you've reached the end of a file in C by using the feof function, which checks for the end-of-file status of the stream.
For efficient memory utilization in dynamic arrays, it is important to release the allocated memory using the function _________.
- free()
- malloc()
- realloc()
- calloc()
The correct option is 'free()'. It is essential to use the free() function to release dynamically allocated memory to avoid memory leaks.
The ________ algorithm is known for its simplicity but is inefficient for sorting large datasets.
- Bubble Sort
- Merge Sort
- Quick Sort
- Selection Sort
The correct option is 'Bubble Sort'. While Bubble Sort is easy to understand, it is not efficient for large datasets due to its O(n^2) time complexity.