Program With Array To Check For Increasing/Decreasing Numbers
<p>Beginner C++ student here starting to learn different ways of using arrays. I am trying to put together the program below. It's supposed to ask the user for an input of a set of numbers that will go into an array. This set of numbers may increase or decrease at any point the user wants.</p>

<p>For example:</p>

<p>1 2 3 4 9 8 7 4 5 6 10 11 12 20 19 18 17</p>

<p>The program is to check against that set of numbers and account for every time there is an increase or decrease. Right now the program will return "increase" or "decrease". </p>

<p>For example, running it against the aforementioned set of numbers it returns:</p>

<p>increasing
decreasing
decreasing</p>

<p>However, I have two problems:</p>

<ol>
<li><p>I think it is not accounting for all the changes (increases and decreases) occurring in the array correctly. Unsure where I have gone wrong.</p></li>
<li><p>I now have to return the number of changes that occur instead of "decrease"/"increase". Meaning, in the example above it would return "3" because there is 1 true value and 2 false.</p></li>
</ol>

<p>If anyone can advise I would immensely appreciate the help.</p>

<p>Thank you so very much!!!</p>

<pre><code>#include &lt;iostream&gt;
using namespace std;

bool increasing(int arr[], int n);


int main()
{
    int arr[20], n;

    cout &lt;&lt; "Enter a set of Increasing/Decreasing numbers (ex. 1 2 3 6 5 4 7 8 9 3 2 1)." &lt;&lt; endl;
    cout &lt;&lt; "Press 'Enter' to see results" &lt;&lt; endl;

    while (cin &gt;&gt; n)
    {
        for (int i = 0; i &lt;= n; i++)
        {
            cin &gt;&gt; arr[i];
        }

        cout &lt;&lt; (increasing(arr, n) ? "increasing" : "decreasing") &lt;&lt; endl;
    }

    return 0;
}



bool increasing(int arr[], int n)
{
    int x = 0;

    for (int i = 0; i &lt; n - 1; i++)
    {
        if (arr[i] &lt; arr[i + 1])
        {
            x++;
        }
    }

    if (x == n - 1)
    {
        return true;
    }
    else
    {
        return false;
    }
}
</code></pre>