diff --git a/misc/geometric_workbench/Makefile b/misc/geometric_workbench/Makefile new file mode 100644 index 0000000..e4c1ef6 --- /dev/null +++ b/misc/geometric_workbench/Makefile @@ -0,0 +1,19 @@ +all: geometric + +geometric: circle.c triangle.c rectangle.c + gcc circle.c -lm -o circle + gcc triangle.c -lm -o triangle + gcc rectangle.c -lm -o rectangle + +circle: circle.c + gcc circle.c -lm -o circle + +triangle: triangle.c + gcc triangle.c -lm -o triangle + +rectangle: rectangle.c + gcc rectangle.c -lm -o rectangle + +clean: + rm rectangle triangle circle + diff --git a/misc/geometric_workbench/README.md b/misc/geometric_workbench/README.md new file mode 100644 index 0000000..772d58f --- /dev/null +++ b/misc/geometric_workbench/README.md @@ -0,0 +1,7 @@ +# Geometric Workbench # +This is just a simple idea I had to create a simple workbench with small tools +to calculate the area of circles, triangles and rectangels. The whole point of +this is to input data to for example the rectangle program and the triangle +program and save those numbers in shell variables and to able to extract the +triangle from the rectangle. To the input is expected to come from STDIN and +output goes to STDOUT. So all those programs can exchange numbers with pipes. diff --git a/misc/geometric_workbench/circle.c b/misc/geometric_workbench/circle.c new file mode 100644 index 0000000..181672d --- /dev/null +++ b/misc/geometric_workbench/circle.c @@ -0,0 +1,15 @@ +#include +#include + +/* Simple program to calculate the area and circumference of a circle. + * Remeber to compile with the -lm option to link the math library. + * The math library includes pow (to the power of) and M_PI (pi). + */ + +int main() +{ + float radius; + scanf("%f", &radius); + printf("%.3f\n", M_PI*(pow(radius, 2))); + return 0; +} diff --git a/misc/geometric_workbench/rectangle.c b/misc/geometric_workbench/rectangle.c new file mode 100644 index 0000000..8930352 --- /dev/null +++ b/misc/geometric_workbench/rectangle.c @@ -0,0 +1,15 @@ +#include +#include + +/* Simple program to calculate the area and circumference of a circle. + * Remeber to compile with the -lm option to link the math library. + * The math library includes pow (to the power of) and M_PI (pi). + */ + +int main() +{ + float b, h; + scanf("%f%f", &b, &h); + printf("%.3f\n", b*h); + return 0; +} diff --git a/misc/geometric_workbench/triangle.c b/misc/geometric_workbench/triangle.c new file mode 100644 index 0000000..f391759 --- /dev/null +++ b/misc/geometric_workbench/triangle.c @@ -0,0 +1,15 @@ +#include +#include + +/* Simple program to calculate the area and circumference of a circle. + * Remeber to compile with the -lm option to link the math library. + * The math library includes pow (to the power of) and M_PI (pi). + */ + +int main() +{ + float b, h; + scanf("%f%f", &b, &h); + printf("%.3f\n", (b*h)/2); + return 0; +} diff --git a/misc/text1.c b/misc/text1.c new file mode 100644 index 0000000..19791b0 --- /dev/null +++ b/misc/text1.c @@ -0,0 +1,11 @@ +#include + +int main() +{ + int c, i, j; + scanf("%d%d%d", &c, &i, &j); + + printf("\n%d\n%d\n%d\n", c, i, j); + + return 0; +}