Introduction to Arrays Presenter: Mrs. McCallum-Rodney.

Slides:



Advertisements
Similar presentations
Etter/Ingber Arrays and Matrices. Etter/Ingber One-Dimensional Arrays 4 An array is an indexed data structure 4 All variables stored in an array are of.
Advertisements

Addison Wesley is an imprint of © 2010 Pearson Addison-Wesley. All rights reserved. Chapter 10 Arrays and Tile Mapping Starting Out with Games & Graphics.
Chapter 8: Arrays.
Arrays and Strings.
Introduction to arrays
An Array A sequence of elements of a particular type Each element in the array has an index which gives its position in the sequence An array is declared.
Programming Logic and Design Sixth Edition
Chapter 10 Introduction to Arrays
CS0007: Introduction to Computer Programming Array Algorithms.
Programming with Alice Computing Institute for K-12 Teachers Summer 2011 Workshop.
Topic 9 – Introduction To Arrays. CISC105 – Topic 9 Introduction to Data Structures Thus far, we have seen “simple” data types. These refers to a single.
Arrays Storing Multiple Values. Motels l If you have a room in a motel and they give you room 5, which room is it?
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Adrian Ilie COMP 14 Introduction to Programming Adrian Ilie July 14, 2005.
Programming with Collections Collections in Java Using Arrays Week 9.
Arrays  Writing a program that uses a large amount of information.  Such as a list of 100 elements.  It is not practical to declare.
Computer Science 1620 Multi-Dimensional Arrays. we used arrays to store a set of data of the same type e.g. store the assignment grades for a particular.
Understanding Arrays and Pointers Object-Oriented Programming Using C++ Second Edition 3.
Chapter Eight: Arrays 1.Terms and what they mean 2.Types of arrays -One Dimensional arrays -Two Dimensional arrays -ragged arrays -Parallel arrays 3. Methods.
Chapter 8: Introduction to High-level Language Programming Invitation to Computer Science, C++ Version, Third Edition.
PHYS 2020 Making Choices; Arrays. Arrays  An array is very much like a matrix.  In the C language, an array is a collection of variables, all of the.
Introduction to Programming with C++ Fourth Edition
Chapter 8: I/O Streams and Data Files. In this chapter, you will learn about: – I/O file stream objects and functions – Reading and writing character-based.
Chapter 9 Introduction to Arrays
Arrays.
Introduction to Arrays CSC 1401: Introduction to Programming with Java Week 10 – Lecture 1 Wanda M. Kunkle.
COMP 14 Introduction to Programming Miguel A. Otaduy June 1, 2004.
CS 106 Introduction to Computer Science I 10 / 16 / 2006 Instructor: Michael Eckmann.
A Level Computing#BristolMet Session Objectives U2#S6 MUST identify different data types used in programming aka variable types SHOULD describe each data.
CPS120: Introduction to Computer Science Arrays. Arrays: A Definition A list of variables accessed using a single identifier May be of any data type Can.
CHAPTER 6: ARRAYS Introduction to Computer Science Using Ruby (c) 2012 Ophir Frieder et al.
INFO Problem Solving and Programming Logic INFO Problem Solving and Programming Logic Arrays Sorting.
Arrays. Arrays: Introduction So far, we handled only one object in each line of code. When we wanted multiple objects to do something, we wrote multiple.
Invitation to Computer Science, Java Version, Second Edition.
A First Book of ANSI C Fourth Edition
Arrays in C++ Numeric Character. Structured Data Type A structured data type is a type that stores a collection of individual components with one variable.
Array Processing.
19/10/20151 Data Structures Arrays. 219/10/2015 Learning Objectives Explain initialising arrays and reading data into arrays. Design and write routine/s.
COMP102 Lab 081 COMP 102 Programming Fundamentals I Presented by : Timture Choi.
1 © 2002, Cisco Systems, Inc. All rights reserved. Arrays Chapter 7.
Array Cs212: DataStructures Lab 2. Array Group of contiguous memory locations Each memory location has same name Each memory location has same type a.
Problem Solving for Programming Session 8 Static Data Structures.
An Object-Oriented Approach to Programming Logic and Design Fourth Edition Chapter 5 Arrays.
Chapter 6: Arrays: Lists and Tables
Coding Design Tools Rachel Gauci. What are Coding Design Tools? IPO charts (Input Process Output) Input- Make a list of what data is required (this generally.
Foundation Studies Course M.Montebello Arrays Foundation Studies Course.
Python Arrays. An array is a variable that stores a collection of things, like a list. For example a list of peoples names. We can access the different.
Programming Logic and Design Fourth Edition, Comprehensive Chapter 8 Arrays.
M1G Introduction to Programming 2 3. Creating Classes: Room and Item.
Arrays. The array data structure Array is a collection of elements, that have the same data type Integers (int) Floating point numbers (float, double)
UniMAP Sem2-10/11 DKT121: Fundamental of Computer Programming1 Arrays.
Chapter 8 Arrays. A First Book of ANSI C, Fourth Edition2 Introduction Atomic variable: variable whose value cannot be further subdivided into a built-in.
Pointers in C++. Topics Covered  Introduction to Pointers  Pointers and arrays  Character Pointers, Arrays and Strings  Examples.
Topic: Control Statements. Recap of Sequence Control Structure Write a program that accepts the basic salary and allowance amount for an employee and.
Data Handling in Algorithms. Activity 1 Starter Task: Quickly complete the sheet 5mins!
Programming Logic and Design Fifth Edition, Comprehensive Chapter 6 Arrays.
For Friday Read No quiz Program 6 due. Program 6 Any questions?
Copyright © 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design Third Edition by Tony Gaddis.
Chapter 9 Introduction to Arrays Fundamentals of Java.
Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 19 A Ray of Sunshine.
Chapter 9: Data types and data structures OCR Computing for A Level © Hodder Education 2009.
KUKUM-06/07 EKT120: Computer Programming 1 Week 6 Arrays-Part 1.
A FIRST BOOK OF C++ CHAPTER 7 ARRAYS. OBJECTIVES In this chapter, you will learn about: One-Dimensional Arrays Array Initialization Arrays as Arguments.
IGCSE 4 Cambridge Data types and arrays Computer Science Section 2
Use proper case (ie Caps for the beginnings of words)
For -G7 programing language Teacher / Shamsa Hassan Alhassouni.
EKT150 : Computer Programming
ARRAYS 1 GCSE COMPUTER SCIENCE.
Starting Out with Programming Logic & Design
Data Types and Data Structures
Programming Logic and Design Fifth Edition, Comprehensive
Presentation transcript:

Introduction to Arrays Presenter: Mrs. McCallum-Rodney

Introduction Variables hold ONE value at a given time Arrays hold MULTIPLE values of the same type under one name.

WHAT ARE ARRAYS? An array is a set of data of the same type grouped together and referred to by one name. Any collection of homogeneous data (data of the same type) is well-suited for storage in arrays.

WHY USE ARRAYS? Arrays provide a mechanism for declaring and accessing several data items with only one identifier, thereby simplifying the task of data management. As programs become larger and more complicated, it becomes increasingly difficult to manage the data. Variable names typically become longer to ensure their uniqueness. And, the number of variable names makes it difficult for the programmer to concentrate on the more important task of correct coding.

Real life example of an array A motel with rooms. It has a collection of rooms, each with its unique number.

Let’s play CHARADEs Rules: 1.Go into your major groups create a list of 10 real life arrays. 2.Each group will choose a representative to act out (no talking or writing) their real life array. The first group to get it correct in one minute will get a point ; the presenting group will also receive a point if they could guide a group to the right answer. 3.No group can present on array already guessed correctly. 4.If the answer is not an array, the presenting group will lose a point.

END OF LESSON ONE

LESSON TWO Structure of Arrays

STRUCTURE OF ONE – DIMENSIONAL ARRAYS? If you will need to store 10 integer numbers and still have access to all numbers entered, then entering the numbers into an array will be appropriate. Consider the following array: Number

STRUCTURE OF ONE – DIMENSIONAL ARRAYS? Number Values How many elements are in the array?10 Each element has a number assigned to it – this is known as the SUBSCRIPT. The subscript identifies each item in the array. If you need to access values from the array, you will need to state the name of the array and the index (subscript) number. The same goes for putting data into the array. Subscript

UNDERSTANDING ARRAYS? Number Values Subscript What is the value in the 4 th element of the array? What is in Number[8]? What is in Number[2]? Where is the value -11 stored? Where is the value 16 stored? Number[7] Number[10]

UNDERSTANDING ARRAYS? STUDENT_NAME ValuesALTEVETAJEWEL-ANNALECIAROXANNERENEESUZAN Subscript What is the name of the array? How many elements are in the array? What is the data type for STUDENT_NAME What is the value in the 5 th element of the array? What is in STUDENT_NAME[2]? Where is the value SUZAN stored? STUDENT_NAME 6 string RENEE JEWEL-ANN STUDENT_NAME[6]

DO THE CROSSWORD PUZZLE ACTIVITY

DECLARING ARRAYS In every algorithm and program you will need to state each variable that you will be using and its data type. This is known as “DECLARING” variables. To declare an integer array called “Number”, to hold 10 values, you will do the following: PSEUDOCODE DECLARE Number AS integer array of size 10

DECLARING ARRAYS Question 1 Declare an array called ‘teachaddr’, to hold addresses of 50 teachers. PSEUDOCODE DECLARE teachaddr AS string array of size 50

DECLARING ARRAYS Question 2 Declare an array called ‘costprice’, to hold the price of 1000 items in store PSEUDOCODE DECLARE costprice AS real array of size 1000

DECLARING ARRAYS Question 3 Declare an array called ‘answer’, to hold the answer of ‘Y’ or ‘N’ for 25 questions in a questionnaire. PSEUDOCODE DECLARE answer AS character array of size 25

ASSIGNING VALUES TO ARRAY ELEMENTS STUDENT_NAME ValuesKerri- Ann Allyandra Subscript Place the value Kerri-Ann into third element of STUDENT_NAME. PSEUDOCODE STUDENT_NAME[3] ← “Kerri-Ann” Place the value Allyandra into last element of STUDENT_NAME. PSEUDOCODE STUDENT_NAME[6] ← “Allyandra”

END OF LESSON TWO

FILLING AN ARRAY using a FOR LOOP Grades Values Subscript12345 Pseudocode segment. FOR count ← 1 TO 5 PRINT “Enter grade for student” READ Grades[count] ENDFOR.

Question: Write an algorithm pseudocode to accept the names and ages of 100 students. FILLING AN ARRAY using a FOR LOOP START DECLARE count AS integer DECLARE sname AS string array of size 100 DECLARE sage AS integer array of size 100 FOR count ← 1 TO 100 PRINT “Enter name of student” READ sname[count] PRINT “Enter the age of student” READ sage[count] ENDFOR STOP

PRINTING VALUES from ARRAY ELEMENTS STUDENT_NAME ValuesKRYSSALSHANICEJODY-GAYEMARSHASARANAMELIA Subscript PRINT the value in first element of STUDENT_NAME. PSEUDOCODE PRINT STUDENT_NAME[1] Print the value in the fourth element of STUDENT_NAME. PSEUDOCODE PRINT STUDENT_NAME[4] KRYSSAL MARSHA

PRINTING ALL VALUES in an ARRAY STUDENT_NAME ValuesKRYSSALSHANICEJODY-GAYEMARSHASARANAMELIA Subscript KRYSSAL SHANICE Pseudocode segment. FOR count ← 1 TO 6 PRINT STUDENT_NAME[count] ENDFOR. JODY-GAYE MARSHA SARAN AMELIA

The End of Lesson on Arrays Hope you have learnt a lot.