while(ptr !nullprintf("\ % "ptr -data)ptr ptr -nextreturn topstruct stack *pop(struct stack *topstruct stack *ptrptr topif(top =nullprintf("\ stack underflow")else top top -nextprintf("\ the value being deleted is% "ptr -data)free(ptr)return topint peek(struct stack *topif(top==nullreturn - else return top ->dataoutput *****main menu**** push pop peek display exit enter your option enter the number to be pushed on stack multiple stacks while implementing stack using an arraywe had seen that the size of the array must be known in advance if the stack is allocated less spacethen frequent overflow conditions will be encountered to deal with this problemthe code will have to be modified to reallocate more space for the array in case we allocate large amount of space for the stackit may result in sheer wastage of memory thusthere lies trade-off between the frequency of overflows and the space allocated soa better solution to deal with this problem is to have multiple stacks or to have more than one stack in the same array of sufficient size figure illustrates this concept stack - - - - stack figure multiple stacks in fig an array stack[nis used to represent two stacksstack and stack the value of is such that the combined size of both the stacks will never exceed while operating on