Multiplying two arrays I would like to ask how I can make my code more simple and effective. I know that this code can be 100% better. I am supposed to load number for each array and then take the 2 arrays (4*3 and 3*4) and multiply them into 3*3 array.

The main point is making thescanf_s for both int a and int b in one "piece of code."

#include "stdafx.h"
#include &lt;cstdlib&gt;
#include &lt;iostream&gt;
#include &lt;cmath&gt;
using namespace std;

int main()
{
    int a[3][4];
    int b[4][3];
    int c[3][3] = { {0, 0, 0}, {0, 0, 0}, {0, 0, 0} };

    for (int j = 0; j != 4; j++)
    {
        for (int l = 0; l != 4; l++)
        {
            cout &lt;&lt; "Zadej a[" &lt;&lt; j &lt;&lt; "," &lt;&lt; l &lt;&lt; "]: ";
            scanf_s("%d", &amp;a[j][l]);
        }
    }

    for (int j = 0; j != 4; j++)
    {
        for (int l = 0; l != 4; l++)
        {
            cout &lt;&lt; "Zadej b[" &lt;&lt; j &lt;&lt; "," &lt;&lt; l &lt;&lt; "]: ";
            scanf_s("%d", &amp;b[j][l]);
        }
    }


    for (int j = 0; j != 3; j++)
    {
        for (int l = 0; l != 3; l++)
        {
            ;
            printf(" |%d| ", c[j][l] += a[j][l] * b[j][l]);
        }
        printf("\n");
    }

    return 0;
}
Don't put everything into one big main()

If you can separate out the reading of inputs and writing of results from the actual multiplications, then it will be easier to test the multiplication code separately.

Avoid non-standard libraries

Here we have "stdafx.h" and scanf_s that aren't part of standard C++.  Ditch those and use the standard facilities (e.g. std::cin &gt;&gt; a[j][l]).

Include what you use

We don't seem to use &lt;cmath&gt; anywhere, so let's drop that.  We'll need &lt;cstdio&gt; for std::printf() - or switch to C++ style output using &lt;iostream&gt;.

Avoid using the whole std namespace

The std namespace isn't one of the few that's designed to be imported wholesale like that, and there's potential for name conflicts when moving to a new standards version.  Specify just the names you need, or just get used to writing std:: - it's intentionally very short.

Use C++ collections

It's easier to work with the C++ collection types such as std::array or std::vector than with raw (C-style) arrays (which decay to pointers when passed as function arguments).