Our built-in calculator. This is the REPL loop used by Terminal Click.
Go to file
Wade Cappa 5d94a5595f adds gitignore to keep the default binary name out of the repo (#1)
Reviewed-on: https://git.terminal.click/TC/tc-calc/pulls/1
Co-authored-by: Wade Cappa <wade.cappa@msn.com>
Co-committed-by: Wade Cappa <wade.cappa@msn.com>
2026-03-22 01:13:50 +00:00
.gitignore adds gitignore to keep the default binary name out of the repo (#1) 2026-03-22 01:13:50 +00:00
LICENSE Initial commit 2026-03-15 17:51:31 +00:00
README.md Update README with instructions 2026-03-15 11:07:22 -07:00
main.c main: Fix build comments 2026-03-15 11:07:41 -07:00
tc_calc.c Add tc_calc library 2026-03-15 10:55:21 -07:00
tc_calc.h Add tc_calc library 2026-03-15 10:55:21 -07:00

README.md

tc-calc

Our built-in calculator. This is the REPL loop used by Terminal Click.

Build Instructions

cc main.c -o calc -lm

Where cc is our C compiler e.g. gcc, clang, zig cc.

How to Use

Run the executable calc to be greeted with the following prompt:

calc>

Now we type any valid arithmetic expression as we would in a Python REPL:

calc> (2+2)*(2+2)
  16
calc>

Notice how we print the output with a bit of spacing followed by a new prompt.

Switching Formats

We can switch between decimal, hexadecimal and binary formats. Use the :dec, :hex, or :bin tags:

calc> :hex
  format: hex
calc> 0xA - 0x9
  0x1
calc>

The default tag is :dec.