Stack Array in Data structure

Stack array in data structure: 
  1. #include<stdio.h>  
  2. int rear=0;  
  3. int front=0;  
  4. int size=5;  
  5. main()  
  6. {  
  7.     int ch;  
  8.   
  9.     void insert();  
  10.     void delete();  
  11.     void isempty();  
  12.     void isfull();  
  13.     void showstack();  
  14.   
  15.     do  
  16.   
  17.      {             //MENU LIST  
  18.     printf("\t===================\n");  
  19.     printf("\t 1:insert\n");  
  20.     printf("\t 2:delete\n");  
  21.     printf("\t 3:isempty\n");  
  22.     printf("\t 4:isfull\n");  
  23.     printf("\t 5:show stack\n");  
  24.     printf("\t 7:stop\n");  
  25.     printf("\t===================\n");  
  26.     printf("enter your choice\n");  
  27.     scanf("%d",&ch);  
  28.   
  29.     switch(ch)  
  30.     {  
  31.         case 1:  // call insert function and BREAK after that  
  32.         {  
  33.             insert();                                  
  34.             break;  
  35.         }  
  36.   
  37.           
  38.         case 2:  // call delete function and BREAK after that  
  39.         {  
  40.             delete();                                  
  41.             break;  
  42.         }  
  43.         case 3:     // call isempty function and BREAK after that  
  44.         {  
  45.             isempty();   
  46.             break;  
  47.         }  
  48.           
  49.         case 4:     // call isfull function and BREAK after that  
  50.         {  
  51.             isfull();   
  52.             break;  
  53.         }  
  54.         case 5:       // call show function and BREAK after that  
  55.         {  
  56.             showstack();  
  57.             break;  
  58.         }      
  59.         case 6:     
  60.         {  
  61.             printf("program ended\n");  
  62.             break;  
  63.         }  
  64.         default:  
  65.         {  
  66.             printf("enter valid choice");  
  67.             break;  
  68.         }  
  69.     }}  
  70.                  // end of do while  
  71.            while(ch!=6);  
  72. }             
  73. //--------------------------------------------------------//  
  74. void insert()   //function to push  
  75. {  
  76.     if(rear==size)  
  77.     {  
  78.         printf("stack is full\n");  
  79.     }  
  80.     else  
  81.     {  
  82.         top=top+1;  
  83.         printf("enter the data\n");  
  84.         scanf("%d",&[top]);  
  85.     }  
  86. }  
  87. //-----------------------------------------------------------//  
  88. void pop()   //function to pop  
  89. {  
  90.     if(top==0)  
  91.       
  92.         printf("stack is empty");  
  93.     else  
  94.     {  
  95.         top=top-1;  
  96.     }  
  97. }  
  98. //----------------------------------------------------------//  
  99. void isempty()   //function to isempty  
  100. {  
  101.     if(top==0)  
  102.         printf("stack is empty");  
  103.     else  
  104.     {  
  105.         printf("stack is not empty");  
  106.     }  
  107. }  
  108. //----------------------------------------------------------//  
  109. void isfull()   //function to isfull  
  110. {  
  111.     if(top==size)  
  112.         printf("stack is full");  
  113.     else  
  114.     {  
  115.         printf("stack is not full");  
  116.     }  
  117. }  
  118. //-----------------------------------------------------------//  
  119. void topofstack() //function to top of stack  
  120. {  
  121.     printf("data top of stack=%d\n",stack[top]);  
  122. }  
  123. //------------------------------------------------------------//  
  124. void show()   //function to show  
  125. {  
  126.     int i;  
  127.     for(i=top;i>=0;--i)  
  128.     {  
  129.         printf("%d\n",stack[i]);  
  130.     }  
  131. }