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).