que:
write a c program to compute having operators and integer values operand. input first line would mention T i.e. number of queries and T rows each for an expression having integers,operators and a symbol #. The symbol # is used to denote end of expression and you can neglect anything that appears in that row after symbol #.
constraints:
max operators = 20
integers range -1000 to 1000.
ignore any symbol after #
No brackets etc. no operators other than mentioned would be valid.
Operators and operands are single spaced .
some operators have two characters eg. >> (there is space between these characters)
Operators:
all in one line have left to right associativity
- / %
<<
< <= > >=
== !=
&
^ (XOR)
|
Query response:
4
1 + 2 * 3 #
1 + 3 - 5 #
4 + 3 & 5 <= 18 #
4 + 3 * 5 <= 18 #
sample output:
7
-1
1
0
I tried to use reverse polish notation to solve but as there are two characters operators and multi digit integers so i am stuck.
Need help!