confusing excercise question | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
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 [ ][ ];

10th Jul 2019, 2:06 AM
Ateeq Ur Rahman
Ateeq Ur Rahman - avatar
2 Answers
+ 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 ๐Ÿ˜Š
10th Jul 2019, 2:25 AM
๐Ÿ‡ฎ๐Ÿ‡ณOmkar๐Ÿ•‰
๐Ÿ‡ฎ๐Ÿ‡ณOmkar๐Ÿ•‰ - avatar
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
10th Jul 2019, 3:43 PM
Ateeq Ur Rahman
Ateeq Ur Rahman - avatar