2 AnswersNew Answer
Stack is when memory is allocated at compile time which definitely means that you know the amount of memory to be assigned to a value or anything when the program starts running. Heap is when memory is allocated dynamically at runtime. It means that you dont know the amount of memory that will be used when the program starts running.
stack *last in first out data structure *used for pass by value type storage *keeps the original copy of data *static in nature, doesn't permits change heap *it's a tree like data structure *used for pass by reference type data *keeps a reference for the actual data *implemented using pointer and address variables *dynamic in nature