Need help: Stack using a pointer in C

115 views Asked by At

I got to solve this program, but I don't really know how to use a Stack using a pointer. If there's anyone that could explain that to me, I would be grateful.

Implement a.t.p. Stack using a pointer and write a subroutine that calculates the value of a logical expression given in prefix form. You need to solve the problem using the stack. Input: a string that represents a logical expression in prefix form Output: the value of the loaded expression For example, the input data:

|0&1|^010

should write: 1 Note: & = AND, | = OR, ^ = XOR, - = NOT

(P.S. Excuse me if there's any mistake, english is not my mother tongue)

1

There are 1 answers

6
Sadique On
  1. First make a Stack data structure,
  2. Take care of operator precedence (if any),
  3. Convert your expression string to RPN
  4. Evaluate using Shunting Yard Algorithm.

This question should be of help to you - How to evaluate arithmetic expression using stack c?.