home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The C Users' Group Library 1994 August
/
wc-cdrom-cusersgrouplibrary-1994-08.iso
/
listings
/
v_10_02
/
1002024b
< prev
next >
Wrap
Text File
|
1991-12-04
|
559b
|
36 lines
main()
{
char op[2];
int i1, i2;
while(1) {
printf("Enter expression: ");
if (scanf("%d %s %d", &i1, op, &i2) == EOF)
break;
push(i1);
push(i2);
if (op[0] == '+')
add();
else if (op[0] == '-')
subtract();
else if (op[0] == '*')
multiply();
else if (op[0] == '/')
divide();
else {
fprintf(stderr, "Unknown operator >%s<\n", op);
pop(); /* discard both operands */
pop();
push(0); /* substitute a zero result */
}
printf("Result = %d\n", pop());
}
return 0;
}