From 442a49ad5a48d417345959b903ae6a6d32d55759 Mon Sep 17 00:00:00 2001 From: Haidong Ji Date: Fri, 15 Apr 2022 15:51:30 -0500 Subject: Great C programming fun Excellent fundamentals and displine training, many tools and techniques exercises: gdb, emacs, valgrind, git --- 02_code1/code1.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 02_code1/code1.c (limited to '02_code1/code1.c') diff --git a/02_code1/code1.c b/02_code1/code1.c new file mode 100644 index 0000000..192da3f --- /dev/null +++ b/02_code1/code1.c @@ -0,0 +1,20 @@ +int max (int num1, int num2) { + //check if num1 is greater than num2 + //if so, your answer is num1 + //otherwise, your answer is num2 + if (num1 > num2) { + return num1; + } + return num2; +} + +int main(void) { + printf("max(42, -69) is %d\n", max(42, -69)); + printf("max(33, 0) is %d\n", max(33, 0)); + printf("max(0x123456, 123456) is %d\n", max(0x123456, 123456)); + //compute the max of 0x451215AF and 0x913591AF and print it out as a decimal number + printf("max(0x451215AF, 0x913591AF) is %d\n", max(0x451215AF, 0x913591AF)); + + return 0; +} + -- cgit v1.2.3