The program compiles perfectly, the problem is the cycle, it does not show me the position
here goes the include of library stdio.h
int main(void)
{ int x, i=0,j=0, a[100];
char sal;
printf("Este programa lee un arreglo de numeros enteros y un numero x, y muestra en pantalla los indices de las posiciones en donde se encuentra ese numero x\n");
do
{
printf("Ingrese un numero: ");
scanf("%i", &a[i]);
i++;
printf("Si desea salir presione s: ");
scanf(" %c", &sal);
}while(sal!='s');
printf("Ingrese el valor de la variable x: ");
scanf("%i", &x);
for (j; j<=i; j++)
{
if(a[i]==x)
printf("%i",i);
}
printf("\n");
}
for(j; j< i; ++j)becauseiis the value of the last input plus one. And in the loop it should beif(a[j] == x) printf("%i ", j). Usej, the running index, noti.for (j; j<=i; j++)The first parameterj;results in the following output from the compiler: "untitled1.c:18:5: warning: statement with no effect [-Wunused-value" Suggest using:for( ; j<=i; j++ )scanf()family of functions: Always check the returned value (not the parameter values) to assure the operation was successful. In all the calls toscanf(), in the posted code, any returned value other than 1 indicates an error occurred#includestatements as making us guess as to which header files you actually included can/will result in the question being ignored