WHAT IS AN ARRAY? FULL INFORMATION ABOUT AN ARRAY?

WHAT IS AN ARRAY?

A group of similar data is called Array. Which are stored in the memory location sorted in the computer's memory. It is a type of data structure in which work can be done very easily with the data stored. The array is also called Subscript Variable.


For example, in a school,, there is a class Array and in another class a student is Array. Now if we want to find a student or student, then we will need his class and Roll No, finding the student in Array Structure is simple. Will or will happen.


WHAT IS AN ARRAY? FULL INFORMATION ABOUT AN ARRAY?


Array required


When we work with a lot of similar data, a lot of Variable Declare will have to be done for it. These variables will be given different names. When any operation will be done on these variables, it will be extremely difficult and apart from that, it will be difficult to remember the variable's name in the program.


So, we can store the same type of data by using an Array. The array will not give different names. There is only one name of Array in it and the number of data items that will be stored in this Array is called the limit of Array. Array's limit array is determined when declaring if we get Roll No. of fifty students. To store, 


we will declare Array as follows -


WHAT IS AN ARRAY



With another example, we will understand Array -


int a[5];


From this array, we can store a maximum of 5 elements. All its elements will be of the same data type. Its five elements will be as follows.


a[0], a[1], a[2], a[3], a[4],


Hence Syntax of Array will be as follows -


Syntax :- data_type  array_name[SIZE];


Array declaration by the compiler


When we declare an Array, the Compiler assigns it a Sequential position in Memory. In memory, it depends on the data type of the Space Array.


Example: - Space in memory for int a [5] will be Allotted as follows -


WHAT IS AN ARRAY



In the above example, a [5] is the name of an Array that has a maximum size of 5, so only a maximum of 5 values ​​can be stored. The type of this array is int If the first element a [0] is at Memory Address 1000, then it's next a [1] address will be at 1002 because an int variable takes 2-byte space in memory. Subsequent elements will take place in memory in a sequential manner. This shows that the Array element can be treated as a variable.


Array Initialization


Array Element can be initialized as a simple variable. For example, Array's name is first of all. After that in elementals no. After that, the Assignment Operator can store the appropriate data type value continuously.


int a[5];


a [0] = 101;

a [1] = 102;

a [2] = 103;

a [3] = 104;

a [4] = 105;


We can also initialize the Array element as follows -


Int a [5] = {100,101,102,103,104,};


Here a [0] = 100 and a [1] = 101, a [2] = 102, a [3] = 103, a [4] = 104 value will be Assign The value in char type will be Assign as follows-


char gender[2] = { ‘M’, ‘F’};

cout <<gender[0];

cout <<gender[1];

AKASH TIMES

I AM AN ENGINEER BY PROFESSION BUT BLOGGER IS MY OLD DAYS DREAM TO CREATE MY OWN SITE FOR THOSE WHO ARE CURIOUS ABOUT MY BIRTHPLACE THEN I AM COMING FROM (INDIA). THE CURRENT CITY LIVES IN NAVI MUMBAI, INDIA

Post a Comment

IF YOU HAVE ANY PROBLEM PLEASE FELL FREE TO CONTACT US BY - AKASH TIMES

PREVIOUS POST NEXT POST