Compare commits
No commits in common. "main" and "beta" have entirely different histories.
6 changed files with 19 additions and 69 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -51,5 +51,5 @@ Module.symvers
|
||||||
Mkfile.old
|
Mkfile.old
|
||||||
dkms.conf
|
dkms.conf
|
||||||
|
|
||||||
# random shit
|
# random shit I test
|
||||||
test.c
|
test.c
|
12
README.md
12
README.md
|
@ -13,10 +13,7 @@ My goal for this project is to write an open sourced mathmatical library for C a
|
||||||
## List of calculators
|
## List of calculators
|
||||||
|
|
||||||
- Hypotenuse calculator (a²+b²=c²)
|
- Hypotenuse calculator (a²+b²=c²)
|
||||||
- Circumference of a Circle
|
|
||||||
- Area of a circle (πr²)
|
- Area of a circle (πr²)
|
||||||
- Area of a Triangle
|
|
||||||
- Area of a Rectangle
|
|
||||||
- Matrix arithmetics (2-D arrays)
|
- Matrix arithmetics (2-D arrays)
|
||||||
- Determinant of 2*2 matrix
|
- Determinant of 2*2 matrix
|
||||||
- Scalar multiplication
|
- Scalar multiplication
|
||||||
|
@ -30,3 +27,12 @@ My goal for this project is to write an open sourced mathmatical library for C a
|
||||||
- Matrix multiplication
|
- Matrix multiplication
|
||||||
- Determinant of n*n matrix
|
- Determinant of n*n matrix
|
||||||
- Matrix support for none integer numbers
|
- Matrix support for none integer numbers
|
||||||
|
- Derivative
|
||||||
|
- Integral
|
||||||
|
- Area
|
||||||
|
- Area of a triangle
|
||||||
|
- Area of a quadralateral
|
||||||
|
- Peremeter
|
||||||
|
- Peremeter of a triangle
|
||||||
|
- Peremeter of a quadralateral
|
||||||
|
- Circumference of a circle
|
17
formulas.h
17
formulas.h
|
@ -29,19 +29,4 @@ double areaOfCircle(double radius)
|
||||||
area = acos(-1) * pow(radius, 2);
|
area = acos(-1) * pow(radius, 2);
|
||||||
|
|
||||||
return area;
|
return area;
|
||||||
};
|
}
|
||||||
|
|
||||||
double areaOfTriangle(double height, double base)
|
|
||||||
{
|
|
||||||
return (height * base)*(1.0/2.0);
|
|
||||||
};
|
|
||||||
|
|
||||||
double areaOfRectangle(double height, double base)
|
|
||||||
{
|
|
||||||
return (height * base);
|
|
||||||
};
|
|
||||||
|
|
||||||
double circumferenceOfCircle(double radius)
|
|
||||||
{
|
|
||||||
return (2 * acos(-1) * radius);
|
|
||||||
};
|
|
47
main.c
47
main.c
|
@ -18,9 +18,6 @@ int main()
|
||||||
printf("\n 6. * Matrix multiplication *");
|
printf("\n 6. * Matrix multiplication *");
|
||||||
printf("\n 7. Scalar matrix multiplication");
|
printf("\n 7. Scalar matrix multiplication");
|
||||||
printf("\n 8. Exponent");
|
printf("\n 8. Exponent");
|
||||||
printf("\n 9. Area of Triangle");
|
|
||||||
printf("\n 10. Area of Rectangle");
|
|
||||||
printf("\n 11. Circumference of Circle");
|
|
||||||
|
|
||||||
printf("\n\n * Stared entries are not fully programmed.");
|
printf("\n\n * Stared entries are not fully programmed.");
|
||||||
printf("\n Enter your choice here:_____");
|
printf("\n Enter your choice here:_____");
|
||||||
|
@ -121,13 +118,13 @@ int main()
|
||||||
|
|
||||||
int numRows;
|
int numRows;
|
||||||
int numColumns;
|
int numColumns;
|
||||||
double scalar;
|
int scalar;
|
||||||
printf("\nPlease enter the number of rows: ");
|
printf("\nPlease enter the number of rows: ");
|
||||||
scanf("%d", &numRows);
|
scanf("%d", &numRows);
|
||||||
printf("\nPlease enter the number of columns: ");
|
printf("\nPlease enter the number of columns: ");
|
||||||
scanf("%d", &numColumns);
|
scanf("%d", &numColumns);
|
||||||
printf("\nPlease enter the scalar multiplier: ");
|
printf("\nPlease enter the scalar multiplier: ");
|
||||||
scanf("%lf", &scalar);
|
scanf("%d", &scalar);
|
||||||
|
|
||||||
scalarMultiplication(numRows, numColumns, scalar);
|
scalarMultiplication(numRows, numColumns, scalar);
|
||||||
|
|
||||||
|
@ -136,7 +133,8 @@ int main()
|
||||||
|
|
||||||
system("clear");
|
system("clear");
|
||||||
printf("\n ~~ Exponenet ~~\n\n");
|
printf("\n ~~ Exponenet ~~\n\n");
|
||||||
double base, exp;
|
double base;
|
||||||
|
double exp;
|
||||||
printf("\nPlease enter the base: ");
|
printf("\nPlease enter the base: ");
|
||||||
scanf("%lf", &base);
|
scanf("%lf", &base);
|
||||||
printf("\nPlease enter the exponent: ");
|
printf("\nPlease enter the exponent: ");
|
||||||
|
@ -146,43 +144,6 @@ int main()
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 9:
|
|
||||||
system("clear");
|
|
||||||
printf("\n ~~ Area of Triangle ~~\n\n");
|
|
||||||
double triBase, triHeight;
|
|
||||||
printf("\nPlease enter the base: ");
|
|
||||||
scanf("%lf", &triBase);
|
|
||||||
printf("\nPlease enter the height: ");
|
|
||||||
scanf("%lf", &triHeight);
|
|
||||||
double triArea = areaOfTriangle(triHeight, triBase);
|
|
||||||
printf("The area of triangle is %lf.\n", triArea);
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 10:
|
|
||||||
system("clear");
|
|
||||||
printf("\n ~~ Area of Rectangle ~~\n\n");
|
|
||||||
double recBase, recHeight;
|
|
||||||
printf("\nPlease enter the base: ");
|
|
||||||
scanf("%lf", &recBase);
|
|
||||||
printf("\nPlease enter the height: ");
|
|
||||||
scanf("%lf", &recHeight);
|
|
||||||
double recArea = areaOfRectangle(recHeight, recBase);
|
|
||||||
printf("The area of rectangle is %lf.\n", recArea);
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 11:
|
|
||||||
system("clear");
|
|
||||||
printf("\n ~~ Circumference of a Circle ~~\n\n");
|
|
||||||
double cirRadius;
|
|
||||||
printf("\nPlease enter the radius: ");
|
|
||||||
scanf("%lf", &cirRadius);
|
|
||||||
double circumference = circumferenceOfCircle(cirRadius);
|
|
||||||
printf("The circumference is %lf.\n", circumference);
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
printf("\n Incorrect input, try again.\n");
|
printf("\n Incorrect input, try again.\n");
|
||||||
};
|
};
|
||||||
|
|
2
makefile
2
makefile
|
@ -1,2 +0,0 @@
|
||||||
all:
|
|
||||||
gcc main.c -lm -o "cli-calc.o"
|
|
|
@ -57,9 +57,9 @@ int matrixAddition(int numRows, int numColumns)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int scalarMultiplication(int numRows, int numColumns, double scalar)
|
int scalarMultiplication(int numRows, int numColumns, int scalar)
|
||||||
{
|
{
|
||||||
double matrix[numRows][numColumns];
|
int matrix[numRows][numColumns];
|
||||||
|
|
||||||
printf("\nEnter elements in matrix of size %d*%d! \n", numRows, numColumns);
|
printf("\nEnter elements in matrix of size %d*%d! \n", numRows, numColumns);
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ int scalarMultiplication(int numRows, int numColumns, double scalar)
|
||||||
{
|
{
|
||||||
for (int j = 0; j < numColumns; j++)
|
for (int j = 0; j < numColumns; j++)
|
||||||
{
|
{
|
||||||
scanf("%lf", &matrix[i][j]);
|
scanf("%d", &matrix[i][j]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ int scalarMultiplication(int numRows, int numColumns, double scalar)
|
||||||
{
|
{
|
||||||
for (int j = 0; j < numColumns; j++)
|
for (int j = 0; j < numColumns; j++)
|
||||||
{
|
{
|
||||||
printf(" %lf ", matrix[i][j] * scalar);
|
printf(" %d ", matrix[i][j] * scalar);
|
||||||
}
|
}
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue