robgeek 0 Light Poster

I am trying to do some arithmetic operation on a stack but I am little confused on how would I implement it.

For instance I have a statement:
add(multiply(2,3),4) which is equal to 2x3 = 6 + 4 = 10.

If I place this on the stack, it would look something like this:

)
4
)
3
2
(
multiply
(
add

My question how would I implement the above function here. In other words what should I do to make the program interpret the paranthesis in the right way, i.e. if you pop out 4, then 3, and then 2, the program multiplies 2x3 and the result + 4 not something else.

Thanks.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.