Skip to content

About

Simple calculator for beginners written in C++

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

10 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 

Repository files navigation

markdown

Interactive C++ Terminal Calculator 🧮

A lightweight, robust command-line calculator built with C++. This project focuses on clean user input handling and a sleek terminal interface.

✨ Key Features

  • Smart UI: Uses ANSI escape codes (\033[A\r) to overwrite input lines, keeping the terminal display clean and professional.
  • Robust Input Handling: Prevents crashes from invalid characters (like letters) using std::cin.clear() and std::numeric_limits.
  • Arithmetic Operations: Supports Addition (+), Subtraction (-), Multiplication (*), and Division (/).
  • Safety First: Includes explicit checks for division-by-zero errors.
  • Tutorial Mode: Built-in guidance to help new users understand the input format.

🚀 Getting Started

Prerequisites

  • A C++ compiler (GCC, Clang, or MSVC).
  • A terminal that supports ANSI escape sequences (VS Code Terminal, Linux/Mac Terminal).

Compilation & Running

  1. Clone the repository: bash git clone https://github.com

  2. Compile the source code: bash g++ -o calculator main.cpp

  3. Run the application: bash ./calculator

🛠️ Implementation Details The calculator uses a while(true) loop to maintain a continuous session. It validates input using a structured check: cpp if (!(cin >> num1 >> op >> num2)) { // Error recovery logic } Use code with caution.

This ensures the program remains stable even when receiving unexpected input formats. 📸 Preview text Calculation: 10 + 5 = 15 Calculation: 20 / 4 = 5 Error: Division by zero! Use code with caution.

Developed by Shawn-Yu-Dev

About

Simple calculator for beginners written in C++

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages