1 / 14

Array

Array. Cs212: DataStructures Lab 2. Array. Group of contiguous memory locations Each memory location has same name Each memory location has same type. a is the name of this array . Array index or subscript. Declaring , Allocating an initialize Arrays.

hedwig
Télécharger la présentation

Array

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Array Cs212: DataStructures Lab 2

  2. Array • Group of contiguous memory locations • Each memory location has same name • Each memory location has same type a is the name of this array Array index or subscript

  3. Declaring , Allocating an initialize Arrays • Declare array of zero (JAVA ) 1- Default Each int is initialized to 0 by default

  4. 2- Or we can use initializer List

  5. Declare array of zero (c++) 1- using Loop 2- Or we can use initializer List OUT PUT

  6. Initialize the array with different value using initializer list (C++) (JAVA) Output

  7. Initialize the array with user inputs (JAVA)

  8. Initialize the array with user inputs (C++) Output

  9. Ex 1: • Calculate value stored in each array element • Initialize elements of 10-element array to even integers start the even number from 2.

  10. Answer: (java)

  11. Answer: (C++) Output

  12. EX2: • Array elements • Can represent a series of values • We can sum these values

  13. Answer: (C++) Output

  14. Answer: (java)

More Related