Hi guys, I am trying to print the odd and even values of an array 10 per row. I keep getting the same number printing out can anyone see if my logic is wrong for identifying the odd and even values? Thank you.
Code:
int array[1000] = {0};
int i = 0;
int j = 0;
int k = 0;
for(i = 0; i<1000; i++)
{
array[i] = rand();
}
i =0;
for(j = 0; j<100; j++)
{
for(k = 0; k<10; k++)
{
printf("%6d", array[i]);
i++;
}
printf("\n");
}
printf("Odd and even\n\n\n");
i = 0;
j = 0;
k = 0;
if (array[i] == (array[i]+1)/2 != 0 )
{
for(j = 0; j<100; j++)
{
for(k = 0; k<10; k++)
{
printf("%6d", array[i]);
i++;
}
printf("\n");
}
printf("&6d", array[i]);
}
else
{
for(j = 0; j<100; j++)
{
for(k = 0; k<10; k++)
{
printf("%6d", array[i]);
system("pause");
}
printf("\n");
}
}
system("pause");
}