An open API service indexing awesome lists of open source software.

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.

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
```