Skip to content

Latest commit

 

History

History
65 lines (42 loc) · 1.1 KB

File metadata and controls

65 lines (42 loc) · 1.1 KB

C Calculator

Description

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.


Features

  • Perform basic math operations:

    1. Addition
    2. Subtraction
    3. Multiplication
    4. Division
  • Handles invalid user input

  • Runs in a loop until the user exits


How It Works

  1. The program takes two numbers and a character representing the operation (A/S/M/D) from the user
  2. It performs the selected operation on the two numbers
  3. It prints the result

How to Run

  1. Compile the code using c compiler :
    Example :
    gcc calc.c -o calc

  2. Run the program
    ./calc

Example

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


What I Learned

  • Using C to perform calculations
  • Handling invalid user input
  • Working with loops
  • Using functions to organize code

Language Used

  • C

Author

Mostafa Oraby