A naive implementation could be something like this;
#include <iostream>
using namespace std;
bool checkArray(int a[], size_t length)
{
if (length < 2)
return true;
else
{
int value = a[0];
for(int i = 1; i < length; ++i)
{
if (a[i] != value)
return false;
}
return true;
}
}
int main()
{
int myArray[3];
myArray[0] = 1;
myArray[1] = 2;
myArray[2] = 1;
cout << (checkArray(myArray, 3) ? "All are same" : "There are different numbers in there!") << endl;
return 0;
}
Hope this helps,
Fredrik