diff options
author | Fudgerboy <91767657+Fudgerboy@users.noreply.github.com> | 2023-12-03 01:55:31 +0000 |
---|---|---|
committer | Fudgerboy <91767657+Fudgerboy@users.noreply.github.com> | 2023-12-03 01:55:31 +0000 |
commit | a2c2af12e8937dbe407f5088ab3d68fd8f57cd27 (patch) | |
tree | 3458be01eb31dfac438e3e6f69c0d87623c7a06c /wk1 | |
parent | b10bc0499111388d13dbc0926f425edc01ba3653 (diff) |
Sat, Dec 2, 2023, 5:55 PM -08:00
Diffstat (limited to 'wk1')
-rw-r--r-- | wk1/agree.c | 15 | ||||
-rw-r--r-- | wk1/ask.c | 10 | ||||
-rw-r--r-- | wk1/calculator.c | 11 | ||||
-rw-r--r-- | wk1/compare.c | 21 | ||||
-rw-r--r-- | wk1/hello.c | 6 | ||||
-rw-r--r-- | wk1/mario.c | 39 | ||||
-rw-r--r-- | wk1/meow.c | 11 |
7 files changed, 113 insertions, 0 deletions
diff --git a/wk1/agree.c b/wk1/agree.c new file mode 100644 index 0000000..0676cd2 --- /dev/null +++ b/wk1/agree.c @@ -0,0 +1,15 @@ +#include <stdio.h> +#include <cs50.h> + +int main(void) +{ + char c = get_char("Do you agree? "); + if (c == 'y' || c == 'Y') + { + printf("Agreed.\n"); + } + else if (c == 'n' || c == 'N') + { + printf("Not agreed.\n"); + } +} diff --git a/wk1/ask.c b/wk1/ask.c new file mode 100644 index 0000000..39a3910 --- /dev/null +++ b/wk1/ask.c @@ -0,0 +1,10 @@ +#include <stdio.h> +#include <cs50.h> + +int main(void) +{ + string first = get_string("What's your first name? "); + char middle = get_char("What's your middle INITIAL? "); + string last = get_string("What's your last name? "); + printf("Hello, %s %c %s\n", first, middle, last); +} diff --git a/wk1/calculator.c b/wk1/calculator.c new file mode 100644 index 0000000..037436d --- /dev/null +++ b/wk1/calculator.c @@ -0,0 +1,11 @@ +#include <stdio.h> +#include <cs50.h> + +int main(void) +{ + long x = get_int("x: "); + long y = get_int("y: "); + + double z = (double) x / (double) y; + printf("%.20f\n", z); +} diff --git a/wk1/compare.c b/wk1/compare.c new file mode 100644 index 0000000..8511597 --- /dev/null +++ b/wk1/compare.c @@ -0,0 +1,21 @@ +#include <stdio.h> +#include <cs50.h> + +int main(void) +{ + int x = get_int("What's x? "); + int y = get_int("What's y? "); + + if (x < y) + { + printf("x is less than y\n"); + } + else if (x > y) + { + printf("x is greater than y\n"); + } + else + { + printf("x is equal to y\n"); + } +} diff --git a/wk1/hello.c b/wk1/hello.c new file mode 100644 index 0000000..927f7b6 --- /dev/null +++ b/wk1/hello.c @@ -0,0 +1,6 @@ +#include <stdio.h> + +int main(void) +{ + printf("hello, world\n"); +} diff --git a/wk1/mario.c b/wk1/mario.c new file mode 100644 index 0000000..b8b4262 --- /dev/null +++ b/wk1/mario.c @@ -0,0 +1,39 @@ +#include <stdio.h> +#include <cs50.h> + +int get_size(void); +void print_grid(int size); + +int main(void) +{ + //Get Size of Grid + int size = get_size(); + //Print Grid + print_grid(size); +} + +int get_size(void) +{ + int n; + do + { + n = get_int("Size: "); + } + while (n < 1); + return n; +} + +void print_grid(size) +{ + for (int i = 0; i < size; i++) + { + for (int j = 0; j < size; j++) + { + printf("#"); + } + printf("\n"); + } +} + + + diff --git a/wk1/meow.c b/wk1/meow.c new file mode 100644 index 0000000..1f511c8 --- /dev/null +++ b/wk1/meow.c @@ -0,0 +1,11 @@ +#include <stdio.h> +#include <cs50.h> + +int main(void) +{ + int x = 36; + for (int i = 0; i < x; i++) + { + printf("meow\n"); + } +} |