area of tri rec and circ
This commit is contained in:
parent
761c706a29
commit
23ece9e47b
3 changed files with 60 additions and 11 deletions
12
README.md
12
README.md
|
@ -13,7 +13,10 @@ My goal for this project is to write an open sourced mathmatical library for C a
|
|||
## List of calculators
|
||||
|
||||
- Hypotenuse calculator (a²+b²=c²)
|
||||
- Circumference of a Circle
|
||||
- Area of a circle (πr²)
|
||||
- Area of a Triangle
|
||||
- Area of a Rectangle
|
||||
- Matrix arithmetics (2-D arrays)
|
||||
- Determinant of 2*2 matrix
|
||||
- Scalar multiplication
|
||||
|
@ -28,11 +31,4 @@ My goal for this project is to write an open sourced mathmatical library for C a
|
|||
- Determinant of n*n matrix
|
||||
- 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
|
||||
- Integral
|
17
formulas.h
17
formulas.h
|
@ -29,4 +29,19 @@ double areaOfCircle(double radius)
|
|||
area = acos(-1) * pow(radius, 2);
|
||||
|
||||
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);
|
||||
};
|
42
main.c
42
main.c
|
@ -18,6 +18,8 @@ int main()
|
|||
printf("\n 6. * Matrix multiplication *");
|
||||
printf("\n 7. Scalar matrix multiplication");
|
||||
printf("\n 8. Exponent");
|
||||
printf("\n 9. Area of Triangle");
|
||||
printf("\n 10. Area of Rectangle");
|
||||
|
||||
printf("\n\n * Stared entries are not fully programmed.");
|
||||
printf("\n Enter your choice here:_____");
|
||||
|
@ -133,8 +135,7 @@ int main()
|
|||
|
||||
system("clear");
|
||||
printf("\n ~~ Exponenet ~~\n\n");
|
||||
double base;
|
||||
double exp;
|
||||
double base, exp;
|
||||
printf("\nPlease enter the base: ");
|
||||
scanf("%lf", &base);
|
||||
printf("\nPlease enter the exponent: ");
|
||||
|
@ -143,6 +144,43 @@ int main()
|
|||
printf("%lf to the power of %lf is equal to %lf.\n", base, exp, num);
|
||||
|
||||
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:
|
||||
printf("\n Incorrect input, try again.\n");
|
||||
|
|
Loading…
Add table
Reference in a new issue