Advertisement
Guest User

Untitled

a guest
Dec 15th, 2019
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include<conio.h>
  4.  
  5. #define max 100
  6. int top,stack[max];
  7.  
  8.  
  9. void push(char x){
  10.  
  11.  
  12. if(top==max-1){
  13. printf("stack overflow");
  14. } else {
  15. stack[++top]=x;
  16. }
  17.  
  18. }
  19.  
  20. void pop(){
  21.  
  22. printf("%c",stack[top--]);
  23. }
  24.  
  25.  
  26. void main()
  27. {
  28.  
  29. char str[50];
  30.  
  31.  
  32. printf("Enetr the desired string:\n");
  33. gets(str);
  34.  
  35.  
  36.  
  37. int len = strlen(str), i;
  38.  
  39.  
  40. for(i=0; i<len; i++)
  41. push(str[i]);
  42.  
  43.  
  44. for(i=0; i<len; i++)
  45. pop();
  46.  
  47. getch();
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement