hmm, weird..
Adding the curly braces at lines 25 and 31 seemed to fix the problem (before I changed line 12 to initialize sum to 0), as I wasn't getting any compile warnings or errors and the program was working correctly...
but when I submitted it to the turn in site, it said there were compile errors
Code:
8 #include <stdio.h>
9
10 int main(void)
11 {
12 int i, j, avg, sum=0, arr[10];
13
14 printf("Enter 10 digits: ");
15 for (i = 0; i < 10; i++) scanf("%d", &arr[i]); /*For each element of array (named 'arr'), scan in a value*/
16 for (i = 0; i < 10; i++) printf("%2d", arr[i]); /*For each element of arr display value*/
17 for (j = 0; j < 10; j++) sum+= arr[j]; /*Compute sum of all elements of array*/
18 avg = (sum/10); /*divide sum by 10 (compute average)*/
19
20 printf("\n");
21 /*printf("%d\n", sum);*/
22 /*printf("%d\n", avg);*/
23
24 for (i = 0; i < 10; i++) /*For each element of arr...*/
25 { if (arr[i]<avg)
26 printf(" <"); /*if value of element < average, print ' <'*/
27 else if (arr[i]==avg) /*else if value of element == average, print ' ='*/
28 printf(" =");
29 else
30 printf(" >");
31 }
32 printf("\n");
33 printf("PROGRAM ENDS\n");
34
35 return 0;
36 }
once I initialized 'sum' to 0 in line 12, the turn in site accepted it. I was thinking that line 17 would initialize 'sum' to 0 on its own in the first iteration of the for loop...guess not. But why the discrepancy? I'm almost positive our teacher said the turn in site uses the same compiler we use to write and test our code
anyway, thanks for the help, guys
EDIT: LMAO, love the quote in your sig brewbuck!!