Code For STACK IMPLEMENTATION.
#include<stdio.h> #include<conio.h> void push(int s[],int max,int *top,int x) { if(*top>=max-1) printf("stack overflow"); else {*top=*top+1; s[*top]=x; } } int pop(int s[],int *top) { if(*top<=-1) { printf("stack underflow"); return 1; } else { int item; item=s[*top+1]; *top=*top-1; return item; } } int peep(int s[],int *top,int max) { if((*top+1-max)<0) return 0; return s[(*top+1-max)]; } void change(int s[],int *top,int max,int m) { if((*top+1-max)<0) printf("stack underflow"); else s[(*top+1-max)]=m; } int isFull(int *top,int max) { if(*top>=max-1) return 1; else return 0; } int isEmpty(int *top) { if(*top<=-1) return 1; else return 0; } void display(int s[],int ...
Comments
Post a Comment