0

Need help regarding printing array by using for loop

Hello, greetings! could anyone help me with the following code to print out the array? I just could not figure out what is wrong with it. Thank you! //what i want: 12345 678910 1112131415 1112131415 678910 12345 //Output. 5101500 00000 00000 00000 00000 5101500 // Code: #include <iostream> using namespace std; int main() { int arr[3][5] = {(1,2,3,4,5), (6,7,8,9,10), (11,12,13,14,15)}; int i,j; for(i=0; i<3; i++) { for(j=0; j<5; j++) { cout<<arr[i][j]; } cout<<endl; } for(i=2; i >= 0; i--) { for(j=0; j<5; j++) { cout<<arr[i][j]; } cout<<endl; } return 0; }

8th Mar 2018, 12:44 PM
Zhiqi Wang
Zhiqi Wang - avatar
2 odpowiedzi
0
thank you for the help Immortal! :-) :-) :-)
8th Mar 2018, 7:03 PM
Zhiqi Wang
Zhiqi Wang - avatar