C Programming Code Examples C > Beginners Lab Assignments Code Examples Program Code - Define array and use it Program Code - Define array and use it #include <stdio.h> void main() { int numbers[18]; /* Array storing 18 values */ int count = 18; /* Number of values to be read */ long sum = 0L; /* Sum of the numbers */ float average = 0.0f; /* Average of the numbers */ int x = 0; /* Loop counter */ printf("\nEnter the 18 numbers:\n"); /* Read the ten numbers to be averaged */ for(x = 0; x < count; x ++) { printf("%2d : ",x+1); scanf("%d", &numbers[x]); /* Read a number */ sum += numbers[x]; /* Add it to sum */ } average = (float)sum/count; /* Calculate the average */ printf("Average of the ten numbers entered is: %f\n", average); }