A simple calculator written in C that supports basic arithmetic operations, parentheses, decimal numbers, and negative numbers.
- Supports addition (
+), subtraction (-), multiplication (x), and division (/). - Handles parentheses for operation precedence.
- Supports decimal numbers and negative numbers.
make reRun the calculator with an expression as an argument:
./calculator "expression"./calculator "3.2+5"
Result = 8.200000./calculator "5x(8-3)"
Result = 25.000000./calculator "-5x(8-3)"
Result = -25.000000make allormake: Compile the project.make re: Clean and rebuild everything.make clean: Remove object files and temporary files.make fclean: Remove compiled binaries and clean files.make debug: Compile with debugging flags (-ggdb3).
The project is structured as follows:
π src
βββ π main.c
βββ π operation.c
βββ π parentheses.c
β
βββ π expression
β βββ π evaluator.c
β βββ π parser.c
β βββ π part.c
β
βββ π utils
β βββ π list.c
β βββ π delete_char.c
β βββ π is_digit.c
β βββ π strtod.c
CFLAGS:-W -Wall -Wextra -O1(Enables warnings for better code quality).CPPFLAGS:-I./include(Includes the header files from theinclude/directory).