Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

BasicCalculator

C++

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.


✨ Features

  • 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++

🚀 Getting Started

Prerequisites

  • C++ compiler (g++, clang, or MSVC)
  • Basic command-line knowledge

Installation

  1. Clone the repository
   git clone https://github.com/Kiran-Sarwar/BasicCalculator.git
   cd BasicCalculator
  1. Compile the program
   g++ -o calculator Basic_Calculator.cpp
  1. Run the calculator
   ./calculator          # On Linux/macOS
   calculator.exe        # On Windows

💻 Usage

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

Example Interaction

Enter your choice: 1
Enter first number: 15
Enter second number: 25
Result: 40.00

📁 Project Structure

BasicCalculator/
├── Basic_Calculator.cpp    # Main source code
├── README.md              # This file
└── .gitignore            # Git configuration

🔧 How It Works

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

🎯 Roadmap

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

📝 License

This project is open source and available under the MIT License.


👤 Author

Kiran Sarwar

  • GitHub: @Kiran-Sarwar Feel free to fork, modify, and use this project for learning purposes!

💬 Feedback & Contributions

Have suggestions or found a bug? Open an issue or pull request—all contributions are welcome! 🤝

About

A simple console-based calculator that performs basic arithmetic operations (addition, subtraction, multiplication, division) and factorial calculation

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages