How to store input values from user in a multidimensional array? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How to store input values from user in a multidimensional array?

I want to store some numbers (which user will enter) in a matrix form, so how can I use 2D array for this purpose? or if there is some other method, then please post that too!

14th Apr 2017, 6:44 PM
Aatmik Jain
Aatmik Jain - avatar
3 Answers
+ 9
cin>>n; for (int i=0;i <n;i++) for (int j=0;j <n;j++) cin>>a [i][j]; For nxn matrix in array a [][]
14th Apr 2017, 6:46 PM
Pixie
Pixie - avatar
+ 9
2 loops are used. 1st loop for the row and second loop for the column. For a 2xw matrix of the form 00 01 10 11 the inputs are entered in the order 00 01 10 11
14th Apr 2017, 6:52 PM
Pixie
Pixie - avatar
0
can you please elaborate it, Thanks!
14th Apr 2017, 6:49 PM
Aatmik Jain
Aatmik Jain - avatar