C examples for Array:Array Element
Uses loops in array processing
#include <stdio.h> #define SIZE 10/* w w w . j a v a2 s .com*/ #define PAR 72 int main(void){ int index, score[SIZE]; int sum = 0; float average; printf("Enter %d scores:\n", SIZE); for (index = 0; index < SIZE; index++) scanf("%d", &score[index]); printf("scores:\n"); for (index = 0; index < SIZE; index++) printf("%5d", score[index]); printf("\n"); for (index = 0; index < SIZE; index++) sum += score[index]; average = (float) sum / SIZE; printf("Sum of scores = %d, average = %.2f\n", sum, average); printf("average - PAR: %.0f.\n", average - PAR); return 0; }