C++ Calculator
A simple command-line calculator built using C++ that performs basic arithmetic operations like addition, subtraction, multiplication, and division.
๐ Features
โ Addition
โ Subtraction
โ๏ธ Multiplication
โ Division
๐ง User-friendly menu-driven interface
- Clone the Repository git clone https://github.com/your-username/cpp-calculator.git cd cpp-calculator
- Compile the Code g++ main.cpp -o calculator
- Run the Program ./calculator ๐ป Usage Run the program Select an operation from the menu Enter two numbers View the result Example Select operation:
- Add
- Subtract
- Multiply
- Divide
Enter choice: 1 Enter two numbers: 5 3
Result: 8
int main() { int choice; double a, b;
cout << "1. Add\n2. Subtract\n3. Multiply\n4. Divide\n";
cin >> choice;
cout << "Enter two numbers: ";
cin >> a >> b;
switch(choice) {
case 1: cout << "Result: " << a + b; break;
case 2: cout << "Result: " << a - b; break;
case 3: cout << "Result: " << a * b; break;
case 4:
if (b != 0)
cout << "Result: " << a / b;
else
cout << "Error! Division by zero.";
break;
default:
cout << "Invalid choice";
}
return 0;
} ๐ฎ Future Improvements Support for advanced operations (square root, power, etc.) GUI-based calculator Continuous calculation mode Input validation enhancements ๐ค Contributing
Contributions are welcome! Feel free to fork the repo and submit a pull request.
๐ License
This project is open-source and available under the MIT License.