Basic Calculator Program - Xiao-XC/C-Practice-Projects GitHub Wiki
Basic-Calculator-Program
Type: Bro Code course project
Date: Sept 2026
Concepts: switch / case / default / break, char operators, scanf(" %c", ...)
What it does
Performs addition, subtraction, multiplication, and division on two numbers based on an operator symbol, with division-by-zero handling.
What I learned
This was my first switch, which is cleaner than chained if/else if for a fixed set of options. A leading space before %c in scanf skips a leftover newline in the input buffer. One known UX issue: dividing by zero still prints a result line after the error, because result is never assigned.
Source
[View the code on GitHub](https://github.com/Xiao-XC/C-Practice-Projects/tree/main/Basic-Calculator-Program)
Back to Home