reduce a 5x5 matrix to an 25 element array in c
<p>I have the following homework problem to witch i can't seem to find the solution.
PROBLEM: Create a 5x5 matrix of integers and check the if any of the elements of the matrix are in the interval [-10,15], and the ones that belong to the interval add to an array of 25 elements. The program should be implemented in C/C++. QUESTION: Now i have written the following code and the problem i have is when i try to transfer the elements that i have found that fit the condition, in the nested for-loop. The trouble is when i cycle through 5 elements and at the same time i iterate 25 elements. How can i do this? Here is my code:</p>

<pre><code>#include &lt;stdio.h&gt;
#include "stdafx.h"


void main()
{
    int i, j, k, l, m;
    int a[5][5];
    int b[25];


    printf("Please enter the elements of the matrix:\n");

    for ( i = 0; i &lt; 5; i++)
    {
        for ( k = 0; k &lt; 5; k++)
        {
            scanf_s("%d", &amp;a[i][k]);
        }
    }

    for ( k = 0; k &lt; 25; k++)
    {
        for ( l = 0; l &lt; 5; l++)
        {
            if (a[k][l] &gt; -10 &amp;&amp; a[k][l] &lt; 15) {
                b[k] = a[k][l];
            }
        }
    }
    printf("The elements which are in the range [-10, 15], are the   following:\n");

    for (m = 0; m &lt; 25; m++)
    {
        printf("%d\n", b[m]);
    }
}
</code></pre>