+ 4

How many elements we can store in the array if we don't mention it's size in C ?

Let's say, int a[] = {1,2,3,4,5........} How many value we can store in it in C ? Also do it work different for different programming languages ?

4th Sep 2018, 5:57 PM
Manish Kumar
Manish Kumar - avatar
6 Respostas
+ 6
You have to provide all values in the {}. Compiler has limits on the program line length and lines count, but they are huge. Also there is a limit on the size of the array itself as a part of the executable, but it is also very huge. Elements count is limited by the size_t type. So, real limit is your computer memory and a storage sizes.
4th Sep 2018, 8:17 PM
Sergey Ushakov
Sergey Ushakov - avatar
+ 1
Array has limited no. of elements
8th Sep 2018, 6:52 PM
Ashish Verma
Ashish Verma - avatar
+ 1
From Javascript-Tutorial: Creating Arrays JavaScript arrays are dynamic, so you can declare an array and not pass any arguments with the Array() constructor. You can then add the elements dynamically. You can add as many elements as you need to. var courses = new Array(); courses[0] = "HTML"; courses[1] = "CSS"; courses[2] = "JS"; courses[3] = "C++";
14th Sep 2018, 11:24 AM
Rolf Straub
Rolf Straub - avatar
0
An array is immutable, meaning that you can't change it's inital size. So a[] would have the size of 5.
4th Sep 2018, 7:42 PM
Jonas Schröter
Jonas Schröter - avatar
0
An array is immutable(fixed size ), meaning that you can't change the size of array and update size every time that is the reason.
14th Sep 2018, 2:55 AM
Ananthavalli A
Ananthavalli A - avatar
0
Depend on the size of the array you allotted it.
23rd Feb 2019, 8:29 AM
Ashish Verma
Ashish Verma - avatar