you can use two 'for loops' to take the input in a 2d array. Basically we can visualize a 2d array as an simple array in which all the individual elements are themselves an array. So the first 'for' loop will is used for traversing the main array index while the 2nd 'for' loop is used to input the elements in the inner array at a particular index.
| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
| a1 | b1 | c1 | d1 | e1 | f1 | g1 | h1 |
| a2 | b2 | c2 | d2 | e2 | f2 | g2 | h2 |
| a3 | b3 | c3 | d3 | e3 | f3 | g3 | h3 |
| a4 | b4 | c4 | d4 | e4 | f4 | g4 | h4 |
for(int i=0 ; i<n1 ; i++){ // n1 is the no. of arrays in the main array\
for(int j=0 ; j<n2;j++){ // n2 is the no. of elements in the subsequent arrays
arr[i][j] = sc.nextInt();
}}