Arrays Author – Subhasis Nayak
What Is an Array? An array is a sequential collection of data storage locations , each of which holds the same type of data. Each storage location is called an element of the array . Each one is called as an element Storage amount 0 Storage amount 1 Storage amount 2 Storage amount 4 Storage amount 5 Storage amount 6
Continue …. An array is a collection of variables of the same type that are referred to through a common name . Arrays are collections of variables , each having the same name but possessing a unique number called a subscript . A specific element in an array is accessed by an index .
Continue …… I sometimes love to say arrays families of variables —of the same data type , such as int or string, stored in the computer’s memory. Each member of the collection has the same name but possesses a unique number called a subscript , which is used to identify it . Individual members of an array are called elements of the array.
Declaring an array You declare an array by writing the certain type It will followed by the array name (array identifier) and subscript. Next, the subscript is the number of elements in the array. Subscript surrounded by the square brackets ‘ [] ’. Number of elements will be in square brackets.
Let’s declare an array. If I want to declare an array of integer type having name numeric & it has 10 elements. I will write like this int numeric[10];
Little backend concept. As we know an compiler allocates 2 byte of space to store integer type of value, so here to store our array numeric compiler will allocates 20 bytes of memory space to the array. Array is a sequential collection of data storage locations. Each element of numeric array is an individual integer.
Do you know ? Do you know array starts from ‘0’. It means the first value will be stored at 0 th place.
Two big things in array. Index = This is the number which is unique . Through which we distinguish the each element of an array. Index value = Each element in an array has a different index value, which are sequential integers starting from 0. It may possible to store same value to two different index but it is never possible having similar index number.
Continue. ….
Accessing Array Elements You access an array element by referring to its offset or it’s index from the beginning of the array. You can’t an index value in your program that’s outside the legal range for an array. Some compiler doesn’t inform you about that, so you have the problem at run time. So, be specific about you’re the array range.
Index & memory address Here this array memory allocation started at ‘1000’ and proceeds
Program 01(initialization separatly )
Program 02(initialization with declaration)
Program 03(initializing through a loop)
Program 04(adding two arrays)
Program 04(Display in reverse ord..)

C++ arrays part1

  • 1.
    Arrays Author –Subhasis Nayak
  • 2.
    What Is anArray? An array is a sequential collection of data storage locations , each of which holds the same type of data. Each storage location is called an element of the array . Each one is called as an element Storage amount 0 Storage amount 1 Storage amount 2 Storage amount 4 Storage amount 5 Storage amount 6
  • 3.
    Continue …. Anarray is a collection of variables of the same type that are referred to through a common name . Arrays are collections of variables , each having the same name but possessing a unique number called a subscript . A specific element in an array is accessed by an index .
  • 4.
    Continue …… Isometimes love to say arrays families of variables —of the same data type , such as int or string, stored in the computer’s memory. Each member of the collection has the same name but possesses a unique number called a subscript , which is used to identify it . Individual members of an array are called elements of the array.
  • 5.
    Declaring an arrayYou declare an array by writing the certain type It will followed by the array name (array identifier) and subscript. Next, the subscript is the number of elements in the array. Subscript surrounded by the square brackets ‘ [] ’. Number of elements will be in square brackets.
  • 6.
    Let’s declare anarray. If I want to declare an array of integer type having name numeric & it has 10 elements. I will write like this int numeric[10];
  • 7.
    Little backend concept.As we know an compiler allocates 2 byte of space to store integer type of value, so here to store our array numeric compiler will allocates 20 bytes of memory space to the array. Array is a sequential collection of data storage locations. Each element of numeric array is an individual integer.
  • 8.
    Do you know? Do you know array starts from ‘0’. It means the first value will be stored at 0 th place.
  • 9.
    Two big thingsin array. Index = This is the number which is unique . Through which we distinguish the each element of an array. Index value = Each element in an array has a different index value, which are sequential integers starting from 0. It may possible to store same value to two different index but it is never possible having similar index number.
  • 10.
  • 11.
    Accessing Array ElementsYou access an array element by referring to its offset or it’s index from the beginning of the array. You can’t an index value in your program that’s outside the legal range for an array. Some compiler doesn’t inform you about that, so you have the problem at run time. So, be specific about you’re the array range.
  • 12.
    Index & memoryaddress Here this array memory allocation started at ‘1000’ and proceeds
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
    Program 04(Display inreverse ord..)