Good night, I would like to know if in this program I am using EOF (end of file) right, that is, as long as I do not type 0, the vector is being allocated and recorded with a value ?? Here is the code below:
#include <stdio.h>
#include <stdlib.h>
int main (void)
{
int i,j, counter = 1,mediaaritmetica, novasequencia;
int* sequencia = NULL;
while (scanf(%d), &sequencia[i] != EOF)
{
sequencia = (int*) realloc(sequencia, counter * sizeof(int));
scanf("%d", &sequencia[i]);
counter++
}
for (j = 0; j < counter ; j++)
{
mediaartimetica += sequencia[j];
}
mediaaritmetica = mediaartimetica/counter - 1;
for ( k = 2, k < counter ; k++)
{
novasequencia = pow(sequencia[k], 2)/mediaaritmetica * (sequencia[k - 2] + sequencia[k -1] + sequencia[k])
printf(".4%d\n", novasequencia);
}
return 0;
}