Arrays
Here we’ll study about the arrays also we’ll discussing over various topics such as declaration of arrays, accessing the values of an array, initialisation of an array, etc
So very first we’ll start with the definition of arrays
Array :- an array is a kind of data structure which is used to store multiple values in a single variable instead of declaring separate variables for each values
Simply we can say that an array is a data structure through which we can store data in memory
Examples of an arrays are :-
array of numbers - 3,4,42,45,32
array of cars - “suzuki”, “audi”, “ford”, “volvo”
Above mentioned are some examples of an array
As above we have seen that the array is a data structure so we need to understand what is data structure
So simply data structure defines how do we store data in memory
And array is a data structure through which we can store the data in memory
Now we’ll see how to declare an array so below with the help of syntax try to understand the declaration of an array
Data Type [ ] array Name;
arrayName = newdataType [ n ];
dataType [ ] arrayName = newdataType[ n ];
Hear in the above example the ‘n’ is for the size of the array
Also once we give the size of an array then we can’t change it’s size
i.e. :- arr[ 10 ] the ‘10’ is the size given to the array and we cannot change the given size of the array
Lets understand with the help of an example
i.e. :- write a program to declear an array
public class arrayIntro {
public static void main (string[ ]args){
//int [ ]marks = new int [ 5 ]
}
}
Hopefully the above mentioned information helped you to introduce array to your program learn more about the arrays by practicing and gathering more knowledge about the arrays
Stay connected with us for further such updates and to get more knowledgeable content
Thankyou
BY :- ADARSH GUPTA
No comments:
Post a Comment