summaryrefslogtreecommitdiff
path: root/02_code1/code1.c
diff options
context:
space:
mode:
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;
+}
+