+ 1
Write a code in C++, that declares an array of int type having the size of user's choice.
23 ответов
+ 3
https://code.sololearn.com/cbaJZnBBgxRA/?ref=app
just keep learning cpp and try to ask google sometimes😉
+ 3
@Timon cuz if he asks such questions he didnt know anything about vectors, dynamic arrays are more easy for understanding
+ 2
Thanks this helped me a lot!
+ 2
@Curios i ve refreshed the code, look
+ 2
@Timon im pretty sure that at the beginning of the studying he doesnt make such big projects to cause memory leaks, time will come and he will use vectors☺
+ 2
@Curios
https://code.sololearn.com/cbaJZnBBgxRA/?ref=app
just take an input of 'm' and fill the array with it
+ 2
Ohh now I get that, here we are using n as
a[n] [n] ;
+ 2
'n' rows, 'm' columns
+ 2
If I give the values 3 and 4 to n and m respectively, does it mean the same as if I have declared an array
a[3] [4] ;
+ 2
@Curios Im sorry) 'n' columns, 'm' rows, was busy, didnt look at variables
+ 1
And how to do the same in 2D array?
+ 1
Yes, I'm beginner in the field of programming.
+ 1
@01ejka I want to declare an 2D array of user's choice
+ 1
No, that's not the case. I want m and n of user's choice declaring as array[m] [n] ;
+ 1
Wow, great thank you so much! @01ejka
Here, m and n stands for what row or column?
0
Ok, it's possible. But why should you do this instead of using a vector?
I mean, yes, there are some edge cases, but generally said, you want to use vectors for array-like data in the heap.
0
Ok, Curios Basant, please don't use this for arrays with a size greater than 10,000,000. Because if you're unlucky, you'll have to start your device again after that. Just in case you get the idea.
- 1
No, if he can't use vectors, he'll do memory leaks with dynamic arrays.
- 1
Just in case you're interested.
https://code.sololearn.com/cLGivOK3G8Hi/?ref=app