C examples for Array:Array Value
Read scores and calculate the average
#include <stdio.h> int main(){/*from w w w.j a va 2 s .c o m*/ int myArray[10] = {1, 5, 2, 5, 3}; int totalPoints = 0; float avg; for (int i=5; i < 10; i++){ printf("What did the player score in game %d? ", i+1); scanf(" %d", &myArray[i]); } for (int i=0; i<10; i++){ totalPoints += myArray[i]; } avg = ((float)totalPoints/10); printf("\n\nThe Player's scoring average is %.1f.\n", avg); return(0); }