Linear search in a array using bool : I need to develop a linear search algorithm that tests whether the array contains testVal

this is what I wrote 
bool Contains(int a[], int arraySize, int testVal)
{
    
        bool contains = 0;
        for (int i = 0; i < arraySize; ++i)
        {
            if (a[i] == testVal)
            {
                contains = true;
                std::cout << "true" << std::endl;
            }
            else if (a[i] != testVal)
            {
                contains = false;
                std::cout << "false" << std::endl;
            }
        }
        return contains; }

When it debugs it prints correctly, but it also prints 19 "false". I guess it has something to do with the array size being 20. I don't how to fix it to only print once without the 19 "false". Can someone tell me what is wrong?


