Question: what is the difference between heap and stack in c++?
Answer: In a stack, the allocation and deallocation is automatically done by whereas, in heap, it needs to be done by the programmer manually. Handling of Heap frame is costlier than handling of stack frame. Memory shortage problem is more likely to happen in stack whereas the main issue in heap memory is fragmentation.