Foundation Studies Course M.Montebello Arrays Foundation Studies Course.

Slides:



Advertisements
Similar presentations
A Short Review Arrays, Pointers and Structures. What is an Array? An array is a collection of variables of the same type and placed in memory contiguously.
Advertisements

UNIT IV.
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.
CS 141 Computer Programming 1 1 Arrays. Outline  Introduction  Arrays  Declaring Arrays  Examples Using Arrays  Sorting Arrays  Multiple-Subscripted.
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.
Arrays I Savitch Chapter 6.1: Introduction to Arrays.
Review of ICS 102. Lecture Objectives To review the major topics covered in ICS 102 course Refresh the memory and get ready for the new adventure of ICS.
Structures. An array allows us to store a collection of variables However, the variables must be of the same type to be stored in an array E.g. if we.
Introduction to Application Programming IST 256 Application Programming for Information Systems Xiaozhong Liu
Variables Pepper. Variable A variable –box –holds a certain type of value –value inside the box can change Example –A = 2B+1 –Slope = change in y / change.
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  Writing a program that uses a large amount of information.  Such as a list of 100 elements.  It is not practical to declare.
Pointer. Warning! Dangerous Curves C (and C++) have just about the most powerful, flexible and dangerous pointers in the world. –Most other languages.
COMP102 – Programming Fundamentals I LA2B (Mon 5-7pm) LA2E (Fri 3-5pm) LA2F (Fri 5-7pm) TA: Jackie Lo.
Arrays. Arrays  When a value is to be used in a program, a variable is declared to hold that value  What about storing the results of exams for a large.
CS 106 Introduction to Computer Science I 02 / 20 / 2008 Instructor: Michael Eckmann.
Java An introduction. Example 1 public class Example1 { public static void main (String [] args) { System.out.println (“This is the first example”); int.
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.
Lecture 5 Arrays A way to organize data © MIT AITI 2003.
Arrays. Arrays  When a value is to be used in a program, a variable is declared to hold that value  What about storing the results of exams for a large.
COMP 14 Introduction to Programming Miguel A. Otaduy June 1, 2004.
03/16/ What is an Array?... An array is an object that stores list of items. Each slot of an array holds an individual element. Characteristics.
Pointers CS362. Pointers A Pointer is a variable that can hold a memory address Pointers can be used to: Indirectly reference existing variables (sometimes.
Program structure Four different storage-class specifications: –Automatic (auto): local to a function, normally declared variables are automatic. Does.
Foundation Studies Course M.Montebello Records Foundation Studies Course.
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.
“Introduction to Programming With Java” Lecture - 6 U MESH P ATIL
Introduction to Arrays in Java Corresponds with Chapter 6 of textbook.
CMSC 202 Arrays. Aug 6, Introduction to Arrays An array is a data structure used to process a collection of data that is all of the same type –An.
COMP102 Lab 081 COMP 102 Programming Fundamentals I Presented by : Timture Choi.
1 © 2002, Cisco Systems, Inc. All rights reserved. Arrays Chapter 7.
Course Title Object Oriented Programming with C++ Course instructor ADEEL ANJUM Chapter No: 05 ARRAY 1 BY ADEEL ANJUM (MSc-cs, CCNA,WEB DEVELOPER) 1.
Review of ICS 102. Lecture Objectives To review the major topics covered in ICS 102 course Refresh the memory and get ready for the new adventure of ICS.
1 Mr. Muhammad Hanif Lecturer Information Technology MBBS Campus Dadu University of SIndh.
Fundamental Programming: Fundamental Programming Introduction to C++
Chapter 8: Arrays and Functions Department of Computer Science Foundation Year Program Umm Alqura University, Makkah Computer Programming Skills
The character data type char. Character type char is used to represent alpha-numerical information (characters) inside the computer uses 2 bytes of memory.
Pascal Programming Arrays and String Type.
1 One Dimensional Arrays Chapter 11 2 "All students to receive arrays!" reports Dr. Austin. Declaring arrays scores :
Arrays: Part Opening Discussion zWhat did we talk about last class? zWhat do you think the picture of memory looks like when we declare.
1 Chapter 12 Arrays. 2 C++ Data Types structured array struct union class address pointer reference simple integral enum char short int long bool floating.
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.
Arrays.
Computer Programming for Engineers
COMPUTER PROGRAMMING. Array C++ provides a data structure, the array, which stores a fixed-size sequential collection of elements of the same type. An.
Arrays. Topics to be Covered... Arrays ◦ Declaration ◦ Assigning values ◦ Array manipulation using loops Multi-dimensional arrays ◦ 2D arrays ◦ Declaration.
Arrays An array is an indexed data structure which is used to store data elements of the same data type. An array is an indexed data structure which is.
Module 1: Array ITEI222 - Advance Programming Language.
POINTERS IN C. Introduction  A pointer is a variable that holds a memory address  This address is the location of another object (typically another.
C++ Array 1. C++ provides a data structure, the array, which stores a fixed-size sequential collection of elements of the same type. An array is used.
Programming for Beginners Martin Nelson Elizabeth FitzGerald Lecture 9: Arrays; Revision Session.
Lecture #15 ARRAYS By Shahid Naseem (Lecturer). 2 ARRAYS DEFINITION An array is a sequence of objects of same data type. The objects in an array are also.
A Sample Program #include using namespace std; int main(void) { cout
1 C++ Data Types structured array struct union class address pointer reference simple integral enum char short int long bool floating float double long.
Introduction to programming in java Lecture 21 Arrays – Part 1.
Beginning C for Engineers Fall 2005 Arrays, 2-D arrays, character strings Bettina Schimanski Lecture 5: Section 2 (9/28/05) Section 4 (9/29/05)
KUKUM-06/07 EKT120: Computer Programming 1 Week 6 Arrays-Part 1.
Windows Programming Lecture 03. Pointers and Arrays.
Department of Computer Science Western Michigan University
Pascal Programming Arrays and String Type.
RECORDS Introduction Declaring a record Using records
Complex data types Complex data types: a data type made of a complex of smaller pieces. Pascal has four very commonly used complex data types: strings,
EKT150 : Computer Programming
Declaration, assignment & accessing
Introduction To Programming Information Technology , 1’st Semester
MSIS 655 Advanced Business Applications Programming
Arrays ICS2O.
Presentation transcript:

Foundation Studies Course M.Montebello Arrays Foundation Studies Course

Foundation Studies Course M.Montebello Introduction An array is a structure which holds many variables, all of the same data type. The array consists of so many elements, each element of the array capable of storing one piece of data (ie, a variable).

Foundation Studies Course M.Montebello Definition An array is defined as follows: array_name = ARRAY [lower..upper] of data_type ; Lower and Upper define the boundaries for the array. Data_type is the type of variable which the array will store, eg, type int, char etc.

Foundation Studies Course M.Montebello Declaring Arrays A typical declaration follows: VAR marks = ARRAY [1..20] of integer; This creates a definition for an array of integers called marks, which has 20 separate locations numbered from 1 to 20. Each of these positions (called an element), holds a single integer.

Foundation Studies Course M.Montebello Assigning Values To assign a value to an element of an array, use marks[2] := 10; This assigns the integer value 10 to element 2 of the marks array. The value or element number (actually its called an index) is placed inside the square brackets. To assign the value stored in an element of an array to a variable, use: Var total:integer; total := marks[1]+marks[2]+ … + marks[10]; This takes the integer stored in element 1 to 10 of the array marks, and makes the integer total equal to it.

Foundation Studies Course M.Montebello Example program Simple; var name : string; maths,english,maltese,total: integer; average: real; begin Write('Enter name of student '); readln(names); write('Enter marks for Maths --> '); readln(maths); write('Enter marks for English --> '); readln(english); write('Enter marks for Maltese --> '); readln(maltese); total:= maths + english + maltese; average:=total/3; end.

Foundation Studies Course M.Montebello Example program Simple_Arrays; var index : integer; names : array [1..10] of string; maths,english,maltese,total: array [1..10] of integer; average: array [1..10] of real; begin for index := 1 to 10 do begin Write('Enter name of student ',Index,': '); readln(names[index]); write('Enter marks for Maths --> '); readln(maths[index]); write('Enter marks for English --> '); readln(english[index]); write('Enter marks for Maltese --> '); readln(maltese[index]); total[index]:= maths[index] + english[index] + maltese[index]; average[index]:=total[index]/3; end; end.

Foundation Studies Course M.Montebello Lab In order to store the telephone numbers of his friends, a programmer decided to make use of two 1-dimensional arrays to store the names and the corresponding phone numbers. GarfieldAsterixTaz … … Write a short program to enter and store up to fifty names and telephone numbers. Ensure that the exact variable declarations are made as well as the correct program syntax in general is used.