Printing all values in a 4x4 multidimensional array

I've been trying to print out a well formatted values of a 4x4 array but well i've not been successful,belows my line of code
1
2
3
4
5
6
7
8
9
10
#include<iostream>
using namespace std;
int main(){
int rows[4]={2,3,4,10};
int colums[4]={4,6,8,20};
cout<<endl; //meaningless,its just to give space
for (n=0;n<=4;n++){cout<<rows[n]<<" ";}
for (m=0;m<=4;m++){cout<<columns[m]<<" ";}
system("pause");
return 0;}
You have declared only 2 1 d arrays.

1
2
3
4
5
6
7
int a[4][4]={2,3,4,10,2,3,4,10,2,3,4,10,2,3,4,10};
for (n=0;n<4;n++)
{
for (m=0;m<4;m++)
{cout<<a[m][n]<<" ";}
cout<<endl;
}
Topic archived. No new replies allowed.