What is the difference between Stack and Heap?

The stack is used for static memory allocation and access to this memory is fast and simple to keep track of. Heap is used for dynamic memory allocation and memory allocation to variables happens at run time. Accessing the heap memory is complex and slower compared to stack.