Stack is a linear data structure whereas a heap is a hierarchical data structure. Stack cannot be resized but a heap can be resized. In stack, memory is allocated in a contiguous block only whereas in a heap, memory is allocated in any random order. The access time of stack is faster while that of the heap is slower. Stack comprises of local variables only but heap allows us to access variables globally. Stack allocation and deallocation is done automatically by compiler instructions whereas the same thing needs to be done manually by a programmer in case of a heap.
Stack image
Heap image