I tried to loop thru an array pointer to get the even numbers in that array.
void even_element(double* a, const int SIZE)
{
for (int count = 0; count < SIZE; count ++)
{
if(a[count] % 2 == 0) //Error here
{
cout << *(a + count) << " ";
}
}
}
I know if I do in the main method where the array is declared, I can do this without using pointer :
for (int count = 0; count < SIZE; count ++)
{
if(num_array[count] % 2 == 0)
{
cout << num_array[count] << " ";
}
}
However, when I try to do this with pointer, I do not know how to loop thru the elements in an array. Can somebody please guide me?
Thanks in advance.