+ 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.
10 Respuestas
+ 4
AteFish thank you bro I am now understanding it 🐸
+ 2
6 elements,
for inside other for
+ 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🧐
+ 2
Wally can I please have a more practical example bro,😩
+ 2
Wally can I please have a more practical example bro,😩
+ 2
Wally can I please have a more practical example bro,😩
+ 1
for(i..){
for(j..){
arr[i][j];
}
}
+ 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;
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;
}
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