I want to replace rows with columns in 2D array, but that doesn't work. The numbers are different in each of the two arrays.
And also in the second array, on second row, and fourth column there is always this same number (4253936).
How can i write it, so i can replace these rows and columns, without any number getting lost? I'm new to c++, So if you can explain it i would be thankfull.
srand(time(NULL));
int tab1[5][4];
// Storing random numbers in array
for(int i = 0;i<5;i++){
for(int j = 0;j<4;j++){
tab1[i][j] = rand()%18-9;
cout<<tab1[i][j]<<' ';
}
cout<<endl;
};
int newtab[4][5];
for(int i = 0; i < 4;i++){
for(int j = 0;j<5;j++){
newtab[i][j] = tab1[j][i];
cout<<newtab[j][i]<<' ';
}
cout<<endl;
}
newtab[i][j]and printingnewtab[j][i]. I suspect the weird number is an uninitalized value