• (2 Pages)
  • +
  • 1
  • 2

Converting and Evaluating Infix, Postfix and Prefix Expressions in C Rate Topic: ***** 6 Votes

#16 young eng  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 23-June 11

Posted 23 June 2011 - 03:48 PM

plz i cant understand the stack operations,and iwant to know if the code is written in c or c++?
Was This Post Helpful? 0
  • +
  • -

#17 Trakker  Icon User is offline

  • A$$hole Extraordinaire.
  • member icon

Reputation: 13
  • View blog
  • Posts: 2,386
  • Joined: 06-June 01

Posted 24 November 2011 - 05:30 PM

Thanks born2code, it's rare to find a clear explanation such as yours on topics such as this.
Appreciate your hard work.
I'll have to poke around at the code later, came here for the explanation of infix - prefix - postfix.

I'd add that after making an expression tree from a given expression, to produce the prefix notation, you write down the element the first time it is seen during traversal, for postfix, you write it down the last time it is seen during traversal. That is how it clicked for me.
Was This Post Helpful? 0
  • +
  • -

#18 dude7788  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 22-September 12

Posted 22 September 2012 - 06:20 PM

Thnx!!
but just one question,in the one with the stack, this only works for displaying the postfix/prefix notation, how would you make the solution of the expression? for example you put 2+4, and this only works to show 2 4 +, but how would you make the actual operation and show the final result, which is 6?

View Postdude7788, on 22 September 2012 - 06:19 PM, said:

Thnx!!
but just one question,in the one with the stack, this only works for displaying the postfix/prefix notation, how would you make the solution of the expression? for example you put 2+4, and this only works to show 2 4 +, but how would you make the actual operation and show the final result, which is 6?

I tried by myself editing the code, but I don't really know how to do it, please
Was This Post Helpful? 0
  • +
  • -

#19 bnsakthi10  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 01-December 12

Posted 01 December 2012 - 03:59 AM

The code is absolutely fine. MY doubt is, why have you subtracted 48 from p's value in line 72 in the code of evaluating expression string.(this line :- push(&stk,*p - 48);)
Was This Post Helpful? 0
  • +
  • -

#20 eseuk  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 25-October 13

Posted 25 October 2013 - 12:12 PM

View PostGuitarded, on 15 December 2008 - 12:52 PM, said:

Great tutorial, thanks!

I've modified it a bit to read multiple digit numbers and doubles for my project. There's only one thing I can't figure out, how do you make it read negative numbers and floating point numbers?


Hi i'm trying to use this code to read multiple digit and evaluate it can you tell me how you did to do it please ?
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2