Why does my test of sign always report “negative”?
问题 The following program should print whether the sum of the elements of the array is positive or negative: #include <stdio.h> #define ARR_SIZE 5 int main() { int array[ARR_SIZE] = {1,-2,3,4,-5}; unsigned sum; int i; for(i=0, sum=0; i < ARR_SIZE; i++) { sum += array[i]; printf("sum %d\n ", sum); } printf("%d\n",sum); if(sum>-1) printf("non negative\n"); else printf("negative\n"); return 0; } The program doesn't do what it is supposed to; it prints 'negative' no matter what array values it