add 2nd assignment

This commit is contained in:
juan 2021-09-28 22:44:09 +08:00
parent 26653397dd
commit 461b156b05
No known key found for this signature in database
GPG key ID: 5C1E5093C74F1DC7
2 changed files with 45 additions and 0 deletions

18
pset2/2-num.c Normal file
View file

@ -0,0 +1,18 @@
#include <stdio.h>
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;
}

27
pset2/3-year.c Normal file
View file

@ -0,0 +1,27 @@
#include <stdio.h>
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;
}