Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

4 Commits
ย 
ย 
ย 
ย 

Repository files navigation

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 โš ๏ธ Handles division by zero errors ๐Ÿ› ๏ธ Technologies Used Language: C++ Compiler: g++ / any C++ compatible compiler Platform: Cross-platform (Windows, Linux, macOS) ๐Ÿ“‚ Project Structure calculator/ โ”‚โ”€โ”€ main.cpp # Main source code โ”‚โ”€โ”€ README.md # Project documentation ๐Ÿš€ Getting Started

  1. Clone the Repository git clone https://github.com/your-username/cpp-calculator.git cd cpp-calculator
  2. Compile the Code g++ main.cpp -o calculator
  3. Run the Program ./calculator ๐Ÿ’ป Usage Run the program Select an operation from the menu Enter two numbers View the result Example Select operation:
  4. Add
  5. Subtract
  6. Multiply
  7. Divide

Enter choice: 1 Enter two numbers: 5 3

Result: 8 โš ๏ธ Error Handling Division by zero is not allowed Invalid menu choices are handled gracefully ๐Ÿ“ธ Sample Code Snippet #include using namespace std;

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.

About

InternSim: Calculator (C++)

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages