A simple CLI calculator written in C that allows users to perform basic arithmetic operations. The program supports addition, subtraction, multiplication, and division with input validation.
-
Perform basic math operations:
- Addition
- Subtraction
- Multiplication
- Division
-
Handles invalid user input
-
Runs in a loop until the user exits
- The program takes two numbers and a character representing the operation (A/S/M/D) from the user
- It performs the selected operation on the two numbers
- It prints the result
-
Compile the code using c compiler :
Example :
gcc calc.c -o calc -
Run the program
./calc
Enter the first letter of the operation (A/S/M/D): a
First number: 20
Second number: 30
The answer is: 50
Do you want to calculate anything else? (y/n): n
- Using C to perform calculations
- Handling invalid user input
- Working with loops
- Using functions to organize code
- C
Mostafa Oraby