How to write a C Program Array Example in C Programming Language ?
Solution For C Program :
/*C Program Array Example.*/
#include <stdio.h>
int main(){
// Enter a few students
int n;
scanf("%d", &n);
//Enter student achievement
int score[1000];
int i;
for( i = 0 ; i < n ; i++ ){
scanf("%d", &score[i]);
}
// Total count
int sum = 0;
for( i = 0 ; i < n ; i++ ){
sum += score[i];
}
// Average count
double average = (double)sum / n;
printf("Average: %lf\n", average);
//Get lower than the average of students' scores
printf("No Pass:");
for( i = 0 ; i < n ; i++ ){
if( score[i] < average ){
printf(" %d", score[i]);
}
}
return 0;
}