diff --git a/COM-1308/26-09-66/asterisk.c b/COM-1308/26-09-66/asterisk.c new file mode 100644 index 0000000..bbf6d86 --- /dev/null +++ b/COM-1308/26-09-66/asterisk.c @@ -0,0 +1,14 @@ +#include + +int main() { + int x; + + for (x; x <= 5; x++) { + printf("*"); + } + + printf("\n"); + return 0; + + // output: ****** +} diff --git a/COM-1308/26-09-66/asterisk_box.c b/COM-1308/26-09-66/asterisk_box.c new file mode 100644 index 0000000..0f3ebd1 --- /dev/null +++ b/COM-1308/26-09-66/asterisk_box.c @@ -0,0 +1,23 @@ +#include + +int main() { + int x, i; + + for (x; x <= 5; x++) { + for (i = 1; i <= 5; i++) { + printf("* "); + } + printf("\n"); + } + + printf("\n"); + return 0; + + /* output: + * * * * * + * * * * * + * * * * * + * * * * * + * * * * * + */ +} diff --git a/COM-1308/26-09-66/pyramid_12345.c b/COM-1308/26-09-66/pyramid_12345.c new file mode 100644 index 0000000..5b5f01d --- /dev/null +++ b/COM-1308/26-09-66/pyramid_12345.c @@ -0,0 +1,23 @@ +#include + +int main() { + int x, i; + + for (x = 1; x <= 5; x++) { + for (i = 1; i <= x; i++) { + printf("%d ", i); + } + printf("\n"); + } + + printf("\n"); + return 0; + + /* output: + 1 + 1 2 + 1 2 3 + 1 2 3 4 + 1 2 3 4 5 + */ +} diff --git a/COM-1308/26-09-66/pyramid_reverse.c b/COM-1308/26-09-66/pyramid_reverse.c new file mode 100644 index 0000000..ddbb6a3 --- /dev/null +++ b/COM-1308/26-09-66/pyramid_reverse.c @@ -0,0 +1,29 @@ +#include + +int main() { + int rows = 5, x, o, i; + + for (x = 1; x <= rows; x++) { + for (i = 1; i <= rows - x; i++) { + printf(" "); + } + + for (o = 1; o <= x; o++) { + printf("* "); + } + + printf("\n"); + } + + printf("\n"); + return 0; + + // clang-format off + /* output: + * + * * + * * * + * * * * + * * * * * + */ +} diff --git a/COM-1308/26-09-66/todo/classroom.url b/COM-1308/26-09-66/todo/classroom.url new file mode 100644 index 0000000..ee4fe5c --- /dev/null +++ b/COM-1308/26-09-66/todo/classroom.url @@ -0,0 +1,2 @@ +[InternetShortcut] +URL=https://classroom.google.com/c/NjE0MzkzNDIzNDI1/a/NTI5MjUyMDY5MTE5/details diff --git a/COM-1308/26-09-66/todo/left_side.c b/COM-1308/26-09-66/todo/left_side.c new file mode 100644 index 0000000..b516cc3 --- /dev/null +++ b/COM-1308/26-09-66/todo/left_side.c @@ -0,0 +1,23 @@ +#include + +int main() { + int x, i; + + for (x = 5; x >= 1; --x) { + for (i = 1; i <= x; ++i) { + printf("* "); + } + printf("\n"); + } + + printf("\n"); + return 0; + + /* output: + * * * * * + * * * * + * * * + * * + * + */ +} diff --git a/COM-1308/26-09-66/todo/right_angled.c b/COM-1308/26-09-66/todo/right_angled.c new file mode 100644 index 0000000..5c6456d --- /dev/null +++ b/COM-1308/26-09-66/todo/right_angled.c @@ -0,0 +1,27 @@ +#include + +int main() { + int x, i; + + for (x = 1; x <= 5; ++x) { + for (i = 1; i < x; ++i) { + printf(" "); + } + for (i = x; i <= 5; ++i) { + printf("* "); + } + printf("\n"); + } + + printf("\n"); + return 0; + + // clang-format off + /* output: + * * * * * + * * * * + * * * + * * + * + */ +} diff --git a/COM-1308/26-09-66/todo/right_side.c b/COM-1308/26-09-66/todo/right_side.c new file mode 100644 index 0000000..44af6ee --- /dev/null +++ b/COM-1308/26-09-66/todo/right_side.c @@ -0,0 +1,28 @@ +#include + +int main() { + int x, i; + + for (x = 1; x <= 5; ++x) { + for (i = 1; i <= 5 - x; ++i) { + printf(" "); + } + + for (i = 1; i <= x; ++i) { + printf("* "); + } + printf("\n"); + } + + printf("\n"); + return 0; + + // clang-format off + /* output: + * + * * + * * * + * * * * + * * * * * + */ +}