A lightweight, console-based calculator written in C++ that performs basic arithmetic operations and factorial calculations. Perfect for learning fundamental C++ concepts like functions, user input/output, and control flow.
- Basic Arithmetic: Addition, subtraction, multiplication, and division
- Factorial Calculation: Compute factorials for non-negative integers
- Simple User Interface: Interactive console-based menu system
- Error Handling: Input validation for smooth operation
- Lightweight: Minimal dependencies—just pure C++
- C++ compiler (g++, clang, or MSVC)
- Basic command-line knowledge
- Clone the repository
git clone https://github.com/Kiran-Sarwar/BasicCalculator.git
cd BasicCalculator- Compile the program
g++ -o calculator Basic_Calculator.cpp- Run the calculator
./calculator # On Linux/macOS
calculator.exe # On WindowsOnce you run the program, you'll see a menu with operation options:
===== BasicCalculator =====
1. Addition
2. Subtraction
3. Multiplication
4. Division
5. Factorial
6. Exit
Enter your choice:
Simply enter your choice number and follow the prompts to input your numbers. The calculator will display the result instantly.
Enter your choice: 1
Enter first number: 15
Enter second number: 25
Result: 40.00
BasicCalculator/
├── Basic_Calculator.cpp # Main source code
├── README.md # This file
└── .gitignore # Git configuration
The calculator uses a simple switch-case structure to handle different operations:
- Arithmetic Operations: Accept two numbers and perform the selected operation
- Factorial: Recursively or iteratively computes n! for non-negative integers
- Input Validation: Checks for valid operator choices and handles edge cases
Future enhancements could include:
- Advanced operations (trigonometric, logarithmic functions)
- Memory function to store previous results
- Decimal precision control
- GUI version using Qt or SFML
- Unit tests for all operations
This project is open source and available under the MIT License.
Kiran Sarwar
- GitHub: @Kiran-Sarwar Feel free to fork, modify, and use this project for learning purposes!
Have suggestions or found a bug? Open an issue or pull request—all contributions are welcome! 🤝