diff --git a/C13/accessing_via_pointers.c b/C13/AccessingViaPointers/accessing_via_pointers.c similarity index 100% rename from C13/accessing_via_pointers.c rename to C13/AccessingViaPointers/accessing_via_pointers.c diff --git a/LC14/LineLength/LineLength.c b/LC14/LineLength/LineLength.c new file mode 100644 index 0000000..214d9c2 --- /dev/null +++ b/LC14/LineLength/LineLength.c @@ -0,0 +1,26 @@ +#include +#include +#include + +float LineLength(float x1, float x2, float y1, float y2); + +int main() +{ + float p1x = 3.4, p2x = 5.7, p1y = 0.0, p2y = 6.8; + float length = 0; + length = LineLength(p1x, p2x, p1y, p2y); + printf("Length = %f", length); + return 0; +} + +float LineLength(float x1, float x2, float y1, float y2) +{ + float result; + float dx = x2-x1; + float dy = y2-y1; + float tol = 1e-10; + if (fabs(dx) < tol && fabs(dy) < tol ) + return -1; + result = sqrt(dx*dx + dy*dy); + return result; +} diff --git a/LC14/pointer_function_example_1.c b/LC14/PointerFunc1/pointer_function_example_1.c similarity index 100% rename from LC14/pointer_function_example_1.c rename to LC14/PointerFunc1/pointer_function_example_1.c diff --git a/LC14/pointer_function_example_2.c b/LC14/PointerFunc2/pointer_function_example_2.c similarity index 100% rename from LC14/pointer_function_example_2.c rename to LC14/PointerFunc2/pointer_function_example_2.c diff --git a/LC15/pointer_to_array_examples.c b/LC15/PointerToArray/pointer_to_array_examples.c similarity index 100% rename from LC15/pointer_to_array_examples.c rename to LC15/PointerToArray/pointer_to_array_examples.c diff --git a/LC15/pointer_to_array_1.c b/LC15/PointerToArray1/pointer_to_array_1.c similarity index 100% rename from LC15/pointer_to_array_1.c rename to LC15/PointerToArray1/pointer_to_array_1.c diff --git a/LC15/pointer_to_array_2.c b/LC15/PointerToArray2/pointer_to_array_2.c similarity index 100% rename from LC15/pointer_to_array_2.c rename to LC15/PointerToArray2/pointer_to_array_2.c