Skip to content

Sakutaroo/Calculator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Calculator

A simple calculator written in C that supports basic arithmetic operations, parentheses, decimal numbers, and negative numbers.

Features

  • Supports addition (+), subtraction (-), multiplication (x), and division (/).
  • Handles parentheses for operation precedence.
  • Supports decimal numbers and negative numbers.

Compilation

make re

Usage

Run the calculator with an expression as an argument:

./calculator "expression"

Examples

./calculator "3.2+5"
Result = 8.200000
./calculator "5x(8-3)"
Result = 25.000000
./calculator "-5x(8-3)"
Result = -25.000000

Available Commands

Build Commands

  • make all or make: 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).

Source Files

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

Compilation Flags

  • CFLAGS: -W -Wall -Wextra -O1 (Enables warnings for better code quality).
  • CPPFLAGS: -I./include (Includes the header files from the include/ directory).

Author

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors