Presentation is loading. Please wait.

Presentation is loading. Please wait.

Array Cs212: DataStructures Lab 2. Array Group of contiguous memory locations Each memory location has same name Each memory location has same type a.

Similar presentations


Presentation on theme: "Array Cs212: DataStructures Lab 2. Array Group of contiguous memory locations Each memory location has same name Each memory location has same type a."— 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 (JAVA) Output (C++)

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)


Download ppt "Array Cs212: DataStructures Lab 2. Array Group of contiguous memory locations Each memory location has same name Each memory location has same type a."

Similar presentations


Ads by Google