Posted By

Implementation of Stack in C Push Pop Display

Education 6

#include<stdio.h>


int s[5]; 


int top=-1; 


void push()


     {


         int value;


         if (top==5-1){


             printf("Stack is Full");


         }


         else


         {


             printf("\nEnter value to push  ");


             scanf("%d",&value);


             top=top+1;


             s[top]=value;


         }


     }


void pop()


     {


         int value;


         if(top==-1){


             printf("\nStack is Empty\n");


         }


         else


         {


             printf("\nDelete your last element was %d ", s[top]);


             top=top-1;


         }


     }


void disp()


     {


         int i;


         if(top==-1){


             printf("\nStack is Empty\n");


         }


         else


         {


             printf("\nStact Elemets is ");


             for(i=top;i>=0;i--)


             printf("%d  ",s[i]);


         }


     }


int main()


 {


     int ch;


     while(1){


         printf("\n###### Menu ######\n");


         printf("1. PUSH\n2. POP\n3. DISPLAY\n4. EXIT \n\n");


         printf("Enter Your Choice:  ");


         scanf("%d",&ch);


         if(ch==1)


             push();


         else if(ch==2)


             pop();


         else if(ch==3)


             disp();


         else if(ch==4)


             break;


         else


             printf("Invalid Choice");


     }


     return 0; 


}    

Implementation of Stack in C Push Pop Display

Login to comment login

Latest Jobs
  • Jessore University of Science & Technology Office Helper Job Circular
    Jessore University of Science & Technology
    Education: S.S.C/ Equivalent
    Experience: 0 Years
    Deadline: 11 Dec 2018
  • Jessore University of Science & Technology Professor  Job Circular
    Jessore University of Science & Technology
    Education: B. Sc. (Hons.) or M. Sc. or equivalent degree
    Experience: 0 Years
    Deadline: 11 Dec 2018
  • Ministry Of Women And Children Affairs Program Officer Job Circular
    Ministry Of Women And Children Affairs
    Education: Masters Degree
    Experience: 0 Years
    Deadline: 26 Nov 2018
  • Ministry Of Women And Children Affairs Assistant Project Director Job Circular
    Ministry Of Women And Children Affairs
    Education: Masters Degree
    Experience: 0 Years
    Deadline: 26 Nov 2018
  • Cabinet Division Office Helper Job Circular
    Cabinet Division
    Education: S.S.C/ Equivalent
    Experience: 0 Years
    Deadline: 26 Nov 2018