Hi everyone,
I am having this error:
What does this mean?Code:error C2296: '%' : illegal, left operand has type 'int *'
Thanks!;)Code://Write a function countEven(int*, int) which receives
//an integer array and its size, and returns the number
//of even numbers in the array.
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
int countEven(int* array, int n)
{
for (int i = 0; i < n; ++i)
{
if (array % 2 == 0) // <----ERROR!
cout << *array << " ";
else
continue;
}
return *array;
}
int main()
{
int el = 0;
cout << "Enter the number of array elements: ";
cin >> el;
int* Array = new int[el]; //dynamic memory allocated
cout << "Enter your array values: " << endl;
for (int i = 0; i < el; ++i)
{
cout << "[" << i << "]: ";
cin >> *(Array + i);
}
cout << "Your array values are: {";
for (int i = 0; i < el; ++i)
{
cout << *(Array + i) << ",";
}
cout << "}" << endl;
cout << "Your even number elements are: {";
countEven(Array, el);
cout << "}" << endl;
delete Array;
Array = 0;
}