Array: It Is a Derived Data Type

Array: It Is a Derived Data Type

<p>Array: It is a derived data type. It is a group of elements of the same type referenced by a single name. An array is a data structure which allows a collective name to be given to a group of elements of all of which have the same data type. An array consists of a series of consecutive data storage locations. An individual element of an array is identified by its own unique index or subscript</p><p>Need for Arrays- Arrays help to make a program simple, easy to code and understand.</p><p>Single(1-d array): An array whose element are specified by a single subscript. It is a collection of finite, homogeneous element. </p><p>Multidimensional array: An array that has more than one subscript is known as multidimensional array. </p><p>Array Declaration: data-type array_name[size] , const int size; float x[size] </p><p>Array Initialization: int list[5]={10,20,30,40,50} or int list[]={10,20,30,40,50}, int a[3]={1,2,3,4,5}- too many intializers error, int b[4]={1,2} the rest b[2] & b[3] will have 0’s in it. </p><p>Unsized Array: C++ allows one to skip declaring size of an array in an array initialization statement. It automatically creates an array long enough to hold all the intializers present. This is known as unsized array. It automatically calculates the dimensions of unsized arrays. E.g. int num[]={1,2,3} it will calculate the size of an array as 3 data elements occupying 2 bytes each.</p>

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    1 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us