Made a simple geometric workbench

This commit is contained in:
Jack-Benny Persson 2015-10-16 23:15:01 +02:00
parent 614d8aa3c8
commit ad9b6457e0
6 changed files with 82 additions and 0 deletions

View 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

View 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.

View 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;
}

View 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;
}

View 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
View 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;
}