Matrix printing

Hi all, so i'm trying to use a function to print 2 matrices, i expect it to print in the 2x2 form but it keeps appearing on a straight line.

The function:
int print(int p, int q){
int first[2][2], second[2][2];
for (p=0;p<2;p++){
for (q=0;q<2;q++){
cout<<first[p][q]<<endl;
}
}
for(p=0;p<2;++p){
for(q=0;q<2;++q)
cout<<second[p][q]<<endl;
}
}
any and all help is appreciated, thank you.
You are putting a newline after every matrix element. For matrix elements on the same row, you should put a space or tab.
oh, thank you.
Topic archived. No new replies allowed.