How to write a C Program Array Example: Average in C Programming Language ?
Solution For C Program :
//C Program Array Example: Average.
#include <stdio.h>
int main(){
int n;
scanf("%d", &n);
int score[1000];
int i;
for( i = 0 ; i < n ; i++ ){
scanf("%d", &score[i]);
}
int sum = 0;
for( i = 0 ; i < n ; i++ ){
sum += score[i];
}
double average = (double)sum / n;
printf("Average: %lf\n", average);
printf("No Pass:");
for( i = 0 ; i < n ; i++ ){
if( score[i] < average ){
printf(" %d", score[i]);
}
}
return 0;
}