+ 2

how to get user input multi dimensional

hey guys. suppose i have int arr[2][3]; first : how many elemnts are in arr second : how do i get user input using a for loop for a multi dimensional array?? third: please explain in full. thank you.

30th Jul 2020, 10:17 PM
Pjc
Pjc - avatar
12 ответов
+ 4
AteFish thank you bro I am now understanding it 🐸
1st Aug 2020, 10:56 AM
Pjc
Pjc - avatar
+ 2
6 elements, for inside other for
30th Jul 2020, 10:23 PM
Wally
Wally - avatar
+ 2
Abhay so are you saying .... Int arr[2][3] For (int I = 0 ; I < ??? ; I++) Cin >> arr[I][I]; Is correct?? And wat do I put in the question marks bro🧐
31st Jul 2020, 8:11 AM
Pjc
Pjc - avatar
+ 2
Wally can I please have a more practical example bro,😩
31st Jul 2020, 8:12 AM
Pjc
Pjc - avatar
+ 2
Wally can I please have a more practical example bro,😩
31st Jul 2020, 8:12 AM
Pjc
Pjc - avatar
+ 2
Wally can I please have a more practical example bro,😩
31st Jul 2020, 8:12 AM
Pjc
Pjc - avatar
+ 1
for(i..){ for(j..){ arr[i][j]; } }
30th Jul 2020, 10:27 PM
Abhay
Abhay - avatar
+ 1
Pjc the array has 6 elements (2×3) For getting user input use this: for(auto& i:arr) for(auto& j:i) cin>>j;
31st Jul 2020, 12:35 PM
Anthony Maina
Anthony Maina - avatar
0
I think I provided enough hint ,and if you can't figure out what to put in the question mark you should go through basics before trying to understand the Multi dimensional array thing here is the code tho, int main() { int a[2][3]; int i; int j; int value; for(i=0;i<2;i++){ for(j=0;j<3;j++){ cin>>value; a[i][j]=value; } } return 0; }
31st Jul 2020, 10:16 AM
Abhay
Abhay - avatar
0
In the for loop I would have written i<(sizeof(a)/sizeof(a[0])) And j<(sizeof(a[0])/sizeof(int)) I don't know if it works
31st Jul 2020, 12:18 PM
Wally
Wally - avatar