1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | #include <stdbool.h>
#include <stdlib.h>
int power(int base, int power) {
int result = base;
for (int i = 0; i < power; i++) {
result *= base;
}
return result;
}
bool is_divisible(int num, int divisor) {
return num % divisor == 0;
}
bool is_even(int num) {
return is_divisible(num, 2);
}
bool is_odd(int num) {
return !is_even(num);
}
const char* get_day_name(int weekday) {
switch(weekday % 7) {
case 1: return "Sunday";
case 2: return "Monday";
case 3: return "Tuesday";
case 4: return "Wednesday";
case 5: return "Thursday";
case 6: return "Friday";
case 7: return "Saturday";
}
return NULL;
}
|
© Copyright 2024 Alexander J. Quinn & David Burnett This content is protected and may not be shared, uploaded, or distributed.