Jump to content

Infix/Postfix & bc dc conversion

- - - - -

  • Please log in to reply
1 reply to this topic

#1
sheepdogg09

sheepdogg09

    Newbie

  • Members
  • Pip
  • 1 posts
Hi, thank you for taking the time to take a look at this.

So here's the deal, my assignment is to write a program that resembles the traditional version of bc. It will translate the more common way of writing arithmetic expressions into postfix form used by the dc utility.
Ok, so there is plenty of info how to write a program to convert to postfix notation, therefore thats not the issue. The issue being, I can't find any info on the bc/dc utilities, and can't really figure out how they choose their output, other than testing thousands of entries and expressions over and over. Our teacher simply expects us to be pros at the unix environment without any prior knowledge or lessons.

Examples of input and output, respectively.
1+2*3 -- 1 2 3*+ps
i=+2; -- li 2+si
a=b=c=0 -- 0dscdsbsa

if(x<4) -- [ 2sy ]s0
y=2; -- lx 4>0

Thanks for any help you may provide.
Paul

#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others
man page bc section 1
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users