From 7681495ebad739d218e036b81fcb6822a1b9a576 Mon Sep 17 00:00:00 2001 From: Alvie Rahman Date: Fri, 6 Oct 2023 15:21:15 +0100 Subject: [PATCH] c11 --- C11/ex2.c | 15 +++++++++++++++ C11/ex3.c | 21 +++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 C11/ex2.c create mode 100644 C11/ex3.c diff --git a/C11/ex2.c b/C11/ex2.c new file mode 100644 index 0000000..cf5dbae --- /dev/null +++ b/C11/ex2.c @@ -0,0 +1,15 @@ +#include + +#define ARRAY_LEN 90 + +int main() { + int i; + float arr[ARRAY_LEN]; + + for (i = 0; i < ARRAY_LEN; i++) { + arr[i] = (float)i; + } + for (i = 0; i < ARRAY_LEN; i++) { + printf("%d %f\n", i, arr[i]); + } +} diff --git a/C11/ex3.c b/C11/ex3.c new file mode 100644 index 0000000..b8fd202 --- /dev/null +++ b/C11/ex3.c @@ -0,0 +1,21 @@ +#include +#include + +#define ARRAY_LEN 90 + +float degrees_to_radians(float degrees) { + return M_PI * degrees / 180.0; +} + +int main() { + int i; + float arr[ARRAY_LEN]; + + for (i = 0; i < ARRAY_LEN; i++) { + arr[i] = degrees_to_radians((float)i); + } + + for (i = 0; i < ARRAY_LEN; i++) { + printf("%d %f\n", i, arr[i]); + } +}