#inlcude<stdio.h> main(){ int a,i=0,j,k=0,stack[5]; for(i=0;i<4;i++){ scanf("%d\n",&stack[i]); } for(i=3;i>=0;i--){ printf("%d\t",stack[i]); } } (or) void push(); void display(); int stack[MAX], top=-1, item; main() { int ch; do { printf("\n\n\n\n1.\tPush\n3.\tDisplay\n"); printf("\nEnter your choice: "); scanf("%d", &ch); switch(ch) { case 1: push(); break; case 2: display(); break; default: printf("\n\nInvalid entry. Please try again...\n"); } } while(ch!=2); {scanf("%d",&ch);} } void push() { if(top == MAX-1) {printf("\n\nStack is full.");} else { printf("\n\nEnter ITEM: "); scanf("%d", &item); top++; stack[top] = item; printf("\n\nITEM inserted = %d", item); } } void display() { int i; if(top == -1) {printf("\n\nStack is empty.");} else { for(i=top; i>=0; i--) {printf("\n%d", stack[i]);} } }</stdio.h>
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)