This is a program that I wrote in C to teach myself about pointers and how they work, as well as to familiarise myself with Ubuntu and the Linux operating system.
This program takes commandline paramaters to calculate a result.
To differentiate between a postfix and an infix expression, use a string of characters before the expression. Make sure each character in the expression is seperated by a space.
Here are the characters that you need to use in order to use the calculator:
- addition: '+'
- subtraction: '-'
- multiplication: 'X'
- division: '/'
- raise to the power of: '^'
This program makes use of a stack structure that I wrote. This structure and the methods that operate on this structure are found in the c file attached. The stack structure is used to convert infix expressions into postfix expressions and eveluate the results of postfix expressions.
Sample commandline commands:
./calculator infix '(' 2 + 3 ')' X '(' 6 ^ 2 ')' ./calculator postfix 2 3 + 6 2 ^ X