https://github.com/sandra1me/c-console-calculator
This is a simple console-based calculator written in C. It is a tool with support for powers, roots, trigonometric functions, factorials, and a history of recent results. It also lets you reuse the previous result in new operations.
https://github.com/sandra1me/c-console-calculator
beginner-friendly c calculator command-line console-application educational math math-functions terminal-app
Last synced: 8 months ago
JSON representation
This is a simple console-based calculator written in C. It is a tool with support for powers, roots, trigonometric functions, factorials, and a history of recent results. It also lets you reuse the previous result in new operations.
- Host: GitHub
- URL: https://github.com/sandra1me/c-console-calculator
- Owner: Sandra1me
- License: mit
- Created: 2025-08-01T06:33:57.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2025-09-03T17:31:10.000Z (10 months ago)
- Last Synced: 2025-09-03T19:35:48.186Z (10 months ago)
- Topics: beginner-friendly, c, calculator, command-line, console-application, educational, math, math-functions, terminal-app
- Language: C
- Homepage:
- Size: 12.7 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# C Console Calculator
This is a simple console-based calculator written in C. It started as a basic exercise to practice control structures, input/output, and error handling. Over time, it evolved into a more complete tool with support for powers, roots, trigonometric functions, factorials, and a history of recent results. It also lets you reuse the previous result in new operations.
## Features
- Basic operations: addition, subtraction, multiplication, division
- Powers and roots
- Trigonometric functions: sine and cosine
- Factorials (only for positive integers)
- Option to reuse the previous result
- Displays the last 5 results in a history list
- Input validation to prevent crashes
- Input buffer cleaning to avoid invalid reads
## Compilation
Use `gcc` to compile the program:
```c
gcc calculator.c -o calculator -lm
```
## Usage
Run the program from the terminal:
```c
./calculator
```
Follow the menu instructions to select an operation. After each operation, you'll be able to decide whether to continue and whether to reuse the previous result. The calculator will also display a list of your last 5 results.
## Example

## Future Improvements
- Add more math functions like tangent or logarithms
- Save result history to a text file
- Improve the interface with a more visual menu system
- Create a GUI version in C++ or another language
## License
This project is licensed under the [MIT Licence](https://choosealicense.com/licenses/mit/). Feel free to use, modify, or distribute it.