c++ 2d array problem

Hi
Can anybody tell me how to use a 2d in a single loop ?
means i have an array of int like int a[5][5];
now i want to put value in this using a single for loop only .
I don't want to use double for loop.
can anybody tell me how to assigning value in a 2d using a single for loop ?
how to print 2d with the help of a single loop ?
how we can use them with pointers ?
1
2
for(int i = 0; i < 25; i++)
   a[i%5][i/5] = i;

If you do output, you may want to add if(i%5 == 4) cout << '\n'; to the loop to get multiple lines.
Topic archived. No new replies allowed.