Skip to content
/ rpc Public

Implementation of a Reverse Polish Notation calculator in C. Stole the idea from "The C Programming Language" book.

Notifications You must be signed in to change notification settings

CrgioYalux/rpc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

How it works

In Reverse Polish Notation, each operator follows its operands.
An infix expression like:

(1 + 2) * (4 - 5)

Is entered like:

1 2 + 4 5 - *

Expected behavior for this tool

  • Base use:
$ rpc 5 5 + 10 2 - *
$ Result: 80
$ rpc 5 5 + 0 /
$ Error: attempt to divide by 0.
$ rcp 123 123 \* 123 - 444 / # need to use \* to escape character
$ Result: 33
  • Using the show steps flag (-s):
$ rpc -s 5 5 + 10 2 - *
$ rpc: 5 5 + 10 2 - *
$ rpc: 10 8 *
$ rpc: 80

TODO

  • Literally do the minimum.
  • Add optional flags.
    • Show steps flag.
  • Support floating-point numbers

Stuff learned

About

Implementation of a Reverse Polish Notation calculator in C. Stole the idea from "The C Programming Language" book.

Topics

Resources

Stars

Watchers

Forks