summaryrefslogtreecommitdiff
path: root/02_code1/code1.c
diff options
context:
space:
mode:
authorHaidong Ji2022-04-15 15:51:30 -0500
committerHaidong Ji2022-04-15 15:51:30 -0500
commit442a49ad5a48d417345959b903ae6a6d32d55759 (patch)
treec7127bb497e5e439018b1915e0136eec2c9cb124 /02_code1/code1.c
Great C programming funHEADmaster
Excellent fundamentals and displine training, many tools and techniques exercises: gdb, emacs, valgrind, git
Diffstat (limited to '02_code1/code1.c')
-rw-r--r--02_code1/code1.c20
1 files changed, 20 insertions, 0 deletions
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;
+}
+