Made a simple geometric workbench
This commit is contained in:
parent
614d8aa3c8
commit
ad9b6457e0
19
misc/geometric_workbench/Makefile
Normal file
19
misc/geometric_workbench/Makefile
Normal file
@ -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
|
||||
|
7
misc/geometric_workbench/README.md
Normal file
7
misc/geometric_workbench/README.md
Normal file
@ -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.
|
15
misc/geometric_workbench/circle.c
Normal file
15
misc/geometric_workbench/circle.c
Normal file
@ -0,0 +1,15 @@
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
|
||||
/* 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;
|
||||
}
|
15
misc/geometric_workbench/rectangle.c
Normal file
15
misc/geometric_workbench/rectangle.c
Normal file
@ -0,0 +1,15 @@
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
|
||||
/* 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;
|
||||
}
|
15
misc/geometric_workbench/triangle.c
Normal file
15
misc/geometric_workbench/triangle.c
Normal file
@ -0,0 +1,15 @@
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
|
||||
/* 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;
|
||||
}
|
11
misc/text1.c
Normal file
11
misc/text1.c
Normal file
@ -0,0 +1,11 @@
|
||||
#include <stdio.h>
|
||||
|
||||
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;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user