Regarding Stacks

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!

operators: Line 1 : * / % Line 2: + -

line3: >> << Line4: < , <= , >, >=

line 5: == , != line 6: & line7: & line8: ^ line9: |

line number shows the preference of operators

Hi @keshari, I have replied to you on personal chat, let me know if you have some other doubt.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.