15 void print_stack(void);
24 static int ungetchar
= '\0';
32 while((type
= getop(s
)) != EOF
)
63 printf("error: zero divisor\n");
69 push((int)(pop()) % (int)(op2
));
71 printf("error: zero divisor\n");
78 push((int)pow(pop(),pop()));
83 case 'q': // square root
93 printf("\t%.8g\n", pop());
96 printf("error: unknown command %s\n", s
);
103 /* push f onto value stack */
109 printf("error: stack full\n");
112 /* pop and return top value from stack */
119 printf("stack empty\n");
124 /* duplicate value at top of stack */
132 /* reverse two vales at top of stack */
142 /* print top two values on stack */
146 printf("%f\t%f\n", val
[sp
], val
[sp
-1]);
148 // printf("Stack is empty!\n");
151 /* get next operator or numberic operand */
156 while ((s
[0] = c
= getch()) == ' ' || c
== '\t')
159 if(!isdigit(c
) && c
!= '.')
163 while(isdigit(s
[++i
] = c
= getch()))
166 while(isdigit(s
[++i
] = c
= getch()))
176 return (bufp
> 0) ? buf
[--bufp
] : getchar();
183 printf("ungetch: too many characters\n");