Maybe this will solve your problem
Code:
#include <stdio.h>
int main(void)
{
int i,sum=0;/*you must explicitly stated what value is sume*/
/*otherwise what is sum++ that is equal undefined value++ and that is unexpected;*/
float avg=5.828f;/*this is float value*/
float f[15],helper[3];
int j,flag=3;
FILE *data;
data = fopen("test.txt","r");
while(feof(data)==0)
{
sum=0;
for( i=0; i<15; i++ )
{
if((fscanf(data," %f",&f[i]))==EOF)
{ flag=i;
for(j=i;j<15;j++)
f[j]=avg+1;/*to ensure if there are less element in array because of EOF*/
break;
}
}
for(j=0,i=3;j<(flag<3 ? flag:3) ;j++,i+=4)/*if you don't want first element(f[0])*/
helper[j]=f[i];
for(j=0;j<(flag<3 ? flag:3);j++)
{
if(helper[j]<avg)
sum++;
}
printf("Number of data that is below average (among first 15 elements) is %d\n",sum);
}
return 0;
}
Try this, I don't have much time to test it properly. If problem still exists I'll try that later