https://github.com/kei-k23/basic-c-calculator
This is a simple command-line calculator program written in C.
https://github.com/kei-k23/basic-c-calculator
c cli
Last synced: 4 months ago
JSON representation
This is a simple command-line calculator program written in C.
- Host: GitHub
- URL: https://github.com/kei-k23/basic-c-calculator
- Owner: Kei-K23
- Created: 2024-08-21T14:11:52.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-08-21T14:13:31.000Z (almost 2 years ago)
- Last Synced: 2025-12-07T05:50:41.095Z (7 months ago)
- Topics: c, cli
- Language: C
- Homepage:
- Size: 1.95 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Basic Calculator
This is a simple command-line calculator program written in `C`. It supports basic arithmetic operations such as addition, subtraction, multiplication, and division, along with advanced operations like square root and power calculation.
## Features
- Addition
- Subtraction
- Multiplication
- Division
- Square Root
- Power Calculation
- Input validation to handle division by zero
## Getting Started
### Prerequisites
To compile and run this program, you'll need:
- A `C` compiler
- A terminal or command prompt
### Compilation
1. Clone or download the repository to your local machine.
2. Open your terminal or command prompt and navigate to the directory containing `main.cpp`.
3. Compile the code using a `C` compiler. For example, using `clang`:
```bash
clang main.c -o calculator
```
## Running the Program
1. Run the program by executing the compiled file:
```bash
./calculator
```
2. The program will display a menu with the available operations. Follow the prompts to perform calculations.
```bash
Basic Calculator Menu:
1. Add
2. Subtract
3. Multiply
4. Divide
5. Square Root
6. Power
7. Exit
Choose an operation: 1
Enter first number: 5
Enter second number: 3
Result: 8
```