This is a simple calculator program written in C language. It allows users to perform basic and advanced mathematical operations. Users can choose between addition, subtraction, multiplication, division, exponentiation, and advanced functionalities such as square root, logarithm, and trigonometric operations.
To compile and run the calculator program, follow these steps:
- Clone the repository or download the source code files.
- Open a terminal and navigate to the directory containing the source code files.
- Compile the program using a C compiler. For example, using gcc:
gcc -o calculator calculator.c -lm
- Run the compiled executable:
./calculator
- Upon running the calculator, you will be prompted to enter your name.
- Enter your name and press Enter.
- Next, enter the first number you want to perform the operation on.
- You will be presented with a menu of operation choices. Enter the number corresponding to the operation you want to perform.
- If you choose a basic operation (addition, subtraction, multiplication, division, or exponentiation), you will be prompted to enter the second number.
- The calculator will display the result of the operation.
- You will be asked if you want to perform more calculations. Enter "yes" to continue or any other input to exit.
- If you choose the advanced functionalities option, you will be presented with a submenu of advanced operations (square root, logarithm, sin, cos, and tan).
- Enter the number corresponding to the advanced operation you want to perform.
- The calculator will display the result of the operation.
- You will be asked if you want to perform more calculations. Enter "yes" to continue or any other input to exit.
The calculator program includes error handling for invalid operands and division by zero. If you enter an invalid operand or attempt to divide by zero, an error message will be displayed, and you will be prompted to try again.
The calculator program uses the math library for advanced mathematical operations. When compiling the program, the -lm flag is used to link the math library.
Contributions to this calculator program are welcome. If you find any issues or want to add new features, please open an issue or submit a pull request.
This calculator program is released under the MIT License. See the LICENSE file for more information.
The calculator program was created by Samuel Ogboye. It is a simple example of a calculator program and can be used as a starting point for more complex calculator applications.