The Advanced Calculator is a versatile and user-friendly C-based application designed to perform a wide range of mathematical operations. It supports basic arithmetic, trigonometric functions, logarithms, factorial calculations, complex number operations, matrix arithmetic, and statistical analysis. The calculator is enhanced with detailed formula hints and formatted outputs to facilitate an intuitive user experience.
- Basic Arithmetic Operations: Addition, Subtraction, Multiplication, Division, and Exponentiation.
- Trigonometric Functions: Sine, Cosine, and Tangent calculations for angles in degrees.
- Logarithmic Functions: Base-10 Logarithm and Square Root.
- Factorials: Calculation of factorials for non-negative integers.
- Complex Numbers: Support for addition, subtraction, multiplication, and division of complex numbers.
- Matrix Operations: Matrix addition and subtraction.
- Statistical Analysis: Calculation of mean, median, and standard deviation.
- User Guidance: Detailed formula hints and help menus for easy navigation.
- Formatted Output: Clear and formatted results for better readability.
To use the Advanced Calculator, you need a C compiler. Follow these steps to set up and run the calculator:
-
Clone the Repository:
git clone https://github.com/mdriyadkhan585/Advanced-calculator-C cd Advanced-calculator-C
-
Compile the Program:
gcc -o calculator Simple.c -lm gcc -o calculator Next-level.c -lm gcc -o calculator main.c -lm
-o calculator
specifies the output executable name.-lm
links the math library required for mathematical functions.
-
Run the Program:
./calculator
Upon launching, the calculator presents a command prompt where users can enter various operations. Here’s a brief overview of how to use each feature:
- Commands:
add
,sub
,mul
,div
,exp
- Input: Enter two numbers separated by space.
- Example:
add 5 3
will output8.00
.
- Commands:
sin
,cos
,tan
- Input: Enter an angle in degrees.
- Example:
sin 30
will output0.50
.
- Commands:
log
,sqrt
- Input: Enter a number.
- Example:
log 100
will output2.00
.
- Command:
fact
- Input: Enter a non-negative integer.
- Example:
fact 5
will output120
.
- Command:
complex
- Input: Enter the real and imaginary parts of two complex numbers, and choose an operation (
+
,-
,*
,/
). - Example:
complex 1 2 3 4 +
will output4.00 + 6.00i
.
- Command:
matrix
- Input: Enter the dimensions of the matrices, followed by the elements of each matrix, and choose an operation (
+
,-
). - Example:
matrix Enter dimensions: 2 2 Matrix 1: 1 2 3 4 Matrix 2: 5 6 7 8 Operation: +
- Command:
stats
- Input: Enter the number of data elements, followed by the data values.
- Example:
stats Enter number of elements: 5 Data: 1 2 3 4 5
Type help
to view a list of commands and their descriptions:
add
: Additionsub
: Subtractionmul
: Multiplicationdiv
: Divisionexp
: Exponentiationsin
: Sine of an anglecos
: Cosine of an angletan
: Tangent of an anglelog
: Logarithm (base 10)sqrt
: Square Rootfact
: Factorial of a non-negative integercomplex
: Operations on complex numbersmatrix
: Matrix addition and subtractionstats
: Statistical calculations (mean, median, standard deviation)help
: Show help menuexit
: Exit the calculator
The Advanced Calculator supports the following formulas:
- Addition: ( \text{num1} + \text{num2} )
- Subtraction: ( \text{num1} - \text{num2} )
- Multiplication: ( \text{num1} \times \text{num2} )
- Division: ( \text{num1} / \text{num2} )
- Exponentiation: ( \text{num1}^{\text{num2}} )
- Sine: ( \sin(\text{angle in degrees}) )
- Cosine: ( \cos(\text{angle in degrees}) )
- Tangent: ( \tan(\text{angle in degrees}) )
- Logarithm (base 10): ( \log_{10}(\text{num}) )
- Square Root: ( \sqrt{\text{num}} )
- Factorial: ( n! )
- Complex Number Addition: ( (a + bi) + (c + di) )
- Complex Number Subtraction: ( (a + bi) - (c + di) )
- Complex Number Multiplication: ( (a + bi) \times (c + di) )
- Complex Number Division: ( \frac{a + bi}{c + di} )
- Matrix Addition: ( [A] + [B] )
- Matrix Subtraction: ( [A] - [B] )
- Mean: ( \frac{\text{sum(data)}}{n} )
- Median: Middle value of sorted data
- Standard Deviation: ( \sqrt{\frac{\text{sum}((\text{data}[i] - \text{mean})^2)}{n}} )