Your function need to return a value. Maybe something like this:
Code:
#include <stdio.h>
int order(unsigned array[], size_t length) {
int result = 0;
for (size_t index = 1; index < length; ++index) {
unsigned left = array[index - 1], right = array[index];
int check = (left < right) ? 1 : (left > right) ? -1 : 0;
if (check != result && index > 1)
return 0;
result = check;
}
return result;
}
void dump(const char* tag, unsigned array[], size_t length) {
printf("%s:", tag);
for (size_t index = 0; index < length; ++index) {
printf(" %u", array[index]);
}
int direction = order(array, length);
if (direction < 0)
puts(" decreasing");
else if (direction > 0)
puts(" increasing");
else
puts(" not ordered");
}
#define LEN(array) sizeof(array) / sizeof(array[0])
int main(void) {
unsigned a[] = {1, 2, 3, 4}, b[] = {5, 8, 3}, c[] = {3, 9}, d[] = {11};
dump("a", a, LEN(a));
dump("b", b, LEN(b));
dump("c", c, LEN(c));
dump("d", d, LEN(d));
}