OA. free
Free
Texas Instruments Embedded Systems & Hardware Embedded Systems & Hardware Medium

19.

Texas Instruments technical mcq question, verified with a worked answer. Free to practise - no sign-up.

Ratio of milk and water

In what ratio must water be mixed with milk to gain 14 2/3% on selling the mixture at cost price?

Choose one option.
Show answer & explanation
Answer: A. A) 7:25

Assigning NULL to the pointer immediately after calling free(ptr) ensures it no longer references deallocated memory, preventing dangling pointer vulnerabilities.

Step-by-step Derivation:
Step 1: free(ptr) releases the allocated memory block on the heap, but ptr still holds the deallocated address (dangling pointer).
Step 2: Subsequent dereference of a dangling pointer causes undefined behavior.
Step 3: Setting ptr = NULL immediately after free(ptr) neutralizes the pointer, preventing dangling references.