Store all the elements of the resultant matrix of size N * N
int * * mat = ( int * * ) malloc ( N * sizeof ( int * ) ) ; for ( int i = 0 ; i < N ; ++ i ) { mat [ i ] = ( int * ) malloc ( N * sizeof ( int ) ) ; }