0
What is array?not understandable
i am not able to understand array please help me with this
4 Antworten
+ 2
we can hold only homogeneous(similar) type of value. Arrays are fixed in size.we can't increase or decrease the size of array.
+ 1
Array its list of smting value, variables ,strings
0
please explain me more
0
Arrays have a fixed size, meaning once you declare an array with a certain number of elements, you cannot increase or decrease the size of the array.
Arrays also begin at 0 rather than 1. This means that in order to create an array with 5 elements, you must declare the array with a size of 4, or n-1, where n is the total number of elements you wish to include.
For example, in the lines:
string name = “John”;
string name2 = “Jane”;
string name3 = “Mary”;
we have created 3 separate string variables with the values of “John”, “Jane”, and “Mary”.
Since each “name” you create will be of the same data type (string), we can more efficiently create an array of strings rather than separate strings:
string names[2] = {“John”, “Jane”, “Mary”};
The “[2]” indicates an array that will include 3 elements.
Here we have declared 3 strings (0 = John, 1 = Jane, 2 = Mary).
In order to access the name “John,” or the first element in the array, we would write names[0], the second element would be names[1], and so on.
I apologize if I made this confusing, I hope I could help!