From 461b156b05541b5d1f6ce2b81bb72f681146ffee Mon Sep 17 00:00:00 2001 From: juan Date: Tue, 28 Sep 2021 22:44:09 +0800 Subject: [PATCH] add 2nd assignment --- pset2/2-num.c | 18 ++++++++++++++++++ pset2/3-year.c | 27 +++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 pset2/2-num.c create mode 100644 pset2/3-year.c diff --git a/pset2/2-num.c b/pset2/2-num.c new file mode 100644 index 0000000..7a1dcef --- /dev/null +++ b/pset2/2-num.c @@ -0,0 +1,18 @@ +#include + +int main(void) { + // initialize variables + int a, b; + scanf("%d %d", &a, &b); + + // print answer (I don't want to assign vars lol) + if (a == b) { + printf("The two numbers are equal."); + } else if (a > b) { + printf("The larger number is %i, the smaller number is %i.", a, b); + } else { + printf("The larger number is %i, the smaller number is %i.", b, a); + } + + return 0; +} diff --git a/pset2/3-year.c b/pset2/3-year.c new file mode 100644 index 0000000..dd22923 --- /dev/null +++ b/pset2/3-year.c @@ -0,0 +1,27 @@ +#include + +int main(void) { + // initialize values + int year; + scanf("%i", &year); + + // calculate values + if (year % 4 == 0) { + if (year % 100 == 0) { + if (year % 400 == 0) { + printf("Yes"); + return 0; + } else { + printf("No"); + return 0; + } + } else { + printf("Yes"); + return 0; + } + } else { + printf("No"); + } + + return 0; +}