Which function is used to allocate memory dynamically at runtime?
Aalloc()
Bmalloc()
Cmemalloc()
Dallocate()
Correct Answer:
B. malloc()
Explanation:
malloc() is the standard C library function for dynamic memory allocation. It returns a void pointer to the allocated memory block, which can be cast to the required data type.
What is the purpose of the break statement in a switch case?
ATo exit the program
BTo exit the current loop or switch
CTo skip the next statement
DTo pause execution
Correct Answer:
B. To exit the current loop or switch
Explanation:
The break statement terminates the current loop or switch block and transfers control to the statement following the loop or switch. Without it, execution continues to the next case (fall-through).