Step 1: IF TOP = MAX-1 PRINT OVERFLOW [END OF IF] Step 2: SET TOP = TOP+1 Step 3: SET STACK[TOP] = VALUE Step 4: END
The function for the stack push operation in C is as follows. Considering stack is declared as int Stack[5], top=-1;
void push( ) { int item ; if (top < 4) { printf ("Enter the number") ; scanf ("%d", & item) ; top = top + 1 ; stack [top] = item ; } else printf ("Stack overflow") ; }