Can we take size of array from user like Enter size and int a[size]; | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

Can we take size of array from user like Enter size and int a[size];

suggeste

26th Aug 2018, 10:06 AM
Shruti Nayak
7 Answers
+ 6
Meet Mehta your answer is incorrect, it will not work outside sololearn
26th Aug 2018, 10:25 AM
code learner
code learner - avatar
+ 5
yes, you can dynamically allocate memory on heap. like this-> int *array = new int[size]; and don't forget to free the memory by , delete array;
26th Aug 2018, 10:19 AM
code learner
code learner - avatar
+ 3
In the case of a static matrix, the compiler will give an error message, either for dynamic matrix example: int x; cin>>x; int *p=new int[x]; 😇😇
26th Aug 2018, 10:20 AM
Ammar Moulla
Ammar Moulla - avatar
+ 3
yeah at run time... by using dynamic memory allocation
26th Aug 2018, 10:34 AM
Aarav Raj
Aarav Raj - avatar
0
If you are asking for this https://code.sololearn.com/cJZIB0g7ZcSG/?ref=app Hope it helps☺️☺️.
26th Aug 2018, 10:19 AM
Meet Mehta
Meet Mehta - avatar
0
What language?
26th Aug 2018, 10:21 AM
ReimarPB
ReimarPB - avatar
0
ya
29th Aug 2018, 3:27 PM
siddalingayya hiremath
siddalingayya hiremath - avatar