- ➕ Addition - Add two numbers
- ➖ Subtraction - Subtract two numbers
- ✖️ Multiplication - Multiply two numbers
- ➗ Division - Divide with zero-check protection
- 📊 Result Display - Immediate calculation output
- 📋 Stack Storage - LIFO history tracking
- 🔄 Complete History - View all past calculations
- 💾 Session Memory - Results stored until exit
- ⚡ Fast Access - Stack-based retrieval
|
|
Press 1 for addition
Press 2 for subtraction
Press 3 for multiplication
Press 4 for division
Press 0 to exit
Enter Your Choice: 1
Enter The First Number: 15.5
Enter The Second Number: 4.5
Result: 20
Enter Your Choice: 4
Enter The First Number: 10
Enter The Second Number: 0
Error dividing by zero
The Recent History is:
20
15.5
8.75
42
Note: History displays in reverse order (most recent first) due to stack LIFO nature.
if(b == 0) {
cout << "Error dividing by zero" << endl;
continue; // Skip storing invalid result
}- Float Support - Handles decimal numbers
- Continuous Operation - Loop until user exits
- Invalid Choice - Graceful menu return
- ✅ Stack data structure implementation
- ✅ LIFO (Last In, First Out) principle
- ✅ Basic arithmetic operations in C++
- ✅ Error handling and input validation
- ✅ Menu-driven program design
- ✅ Float precision handling
g++ -o calculator SimpleCalculatorWithHistory.cpp
./calculatorEnter Your Choice: 1
Enter The First Number: 25
Enter The Second Number: 15
Result: 40
Enter Your Choice: 0
The Recent History is:
40
- 🧮 Advanced Operations - Power, square root, trigonometry
- 📁 File Storage - Save history to file
- 🔄 History Navigation - Search and reuse previous results
- 🎨 GUI Interface - Visual calculator design
- 📊 Expression Parsing - Handle complex expressions
🧮 Calculate with Confidence! 📊