{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

array - Programming Arrays 102 Prog Fundamentals I Arrays...

Info icon This preview shows pages 1–8. Sign up to view the full content.

View Full Document Right Arrow Icon
Arrays Programming
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
P102 Prog. Fundamentals I: Arrays / Slide 2 Arrays An array is a collection of data elements that are of the same type (e.g., a collection of integers, collection of characters, collection of doubles).
Image of page 2
P102 Prog. Fundamentals I: Arrays / Slide 3 Arrays 1-dimensional array. 3-dimensional array (3rd dimension is the day). Oct 15 Oct 16 Oct 14
Image of page 3

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
P102 Prog. Fundamentals I: Arrays / Slide 4 Array Applications Given a list of test scores, determine the maximum and minimum scores. Read in a list of student names and rearrange them in alphabetical order (sorting). Given the height measurements of students in a class, output the names of those students who are taller than average.
Image of page 4
P102 Prog. Fundamentals I: Arrays / Slide 5 Array Declaration Syntax: <type> <arrayName>[<array_size>] Ex. int Ar[10]; The array elements are all values of the type <type>. The size of the array is indicated by <array_size> , the number of elements in the array. <array_size> must be an int constant or a constant expression. Note that an array can have multiple dimensions.
Image of page 5

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
P102 Prog. Fundamentals I: Arrays / Slide 6 Array Declaration // array of 10 uninitialized ints int Ar[10]; -- -- -- -- Ar -- -- -- -- -- -- 4 5 6 3 0 2 8 9 7 1 0 1 2 3 4 5
Image of page 6
P102 Prog. Fundamentals I: Arrays / Slide 7 Subscripting Declare an array of 10 integers: int Ar[10]; // array of 10 ints To access an individual element we must apply a subscript to array named Ar. A subscript is a bracketed expression. The expression in the brackets is known as the index. First element of array has index 0. Ar[0] Second element of array has index 1, and so on.
Image of page 7

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 8
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern