0
confusing excercise question
can someone tell me that this question is wrong , I think it is , Type in a row to declare a multidimensional array with 2 rows and 3 columns. Enter the value using cin for the element in the second column of the second row. int arr[2][ ]; cin >> arr [ ][ ];
2 odpowiedzi
+ 3
I think this is right question 😊.
to declare array of integers with rows and columns (matrix form)
Syntax:
int array_name[rows][columns];
So first fill in blank.
int arr[2][3];
Remember array index starts from 0.
So if you want to access element at n-th row and m-th column.
You'll have to write arr[n-1][m-1];
so to input element at location =>
2nd column and 2nd row
cin>>arr[1][1];
To see how elements are indexed see this image:
https://cdn.programiz.com/sites/tutorial2program/files/two-dimensional-array_0.jpg
And read this article :
https://www.programiz.com/c-programming/c-multi-dimensional-arrays
Happy learning 😊
0
Thanks actually I did realize later that the question was correct
I thought 1 would be used for declaring 2 rows then I realized that happens in index
thanks you were helpful. I didn't knew I would get a reply so quick and with so much detail