Chapter 71 Using Part of an Array Sometimes we do not know how many elements will be needed in an array. We can declare a large array, say of 100 elements,

Slides:



Advertisements
Similar presentations
Chapter 11 Introduction to Programming in C
Advertisements

DATA STRUCTURES USING C++ Chapter 5
Introduction to Programming Lecture 15. In Today’s Lecture Pointers and Arrays Manipulations Pointers and Arrays Manipulations Pointers Expression Pointers.
What is a pointer? First of all, it is a variable, just like other variables you studied So it has type, storage etc. Difference: it can only store the.
1 Today’s lecture  Last lecture we started talking about control flow in MIPS (branches)  Finish up control-flow (branches) in MIPS —if/then —loops —case/switch.
Arrays Chapter 6. Outline Array Basics Arrays in Classes and Methods Sorting Arrays Multidimensional Arrays.
Introduction to Computing Dr. Nadeem A Khan. Lecture 10.
Ch. 101 Changing the Contents of a Database. Ch. 102 Changing the Contents of a Database Data grid views can also be used to add, modify, and delete records.
Introduction to Computing Dr. Nadeem A Khan. Lecture 4.
Arrays-Part 1. Objectives Declare and initialize a one-dimensional array Store data in a one-dimensional array Display the contents of a one-dimensional.
Microsoft Visual Basic 2005: Reloaded Second Edition Chapter 8 Arrays.
Introduction to Arrays Chapter 7 Why use arrays? To store & represent lists of homogeneous values To simplify program code To eliminate the need to reread.
11-1 Chapter 11 2D Arrays Asserting Java Rick Mercer.
1 Lab Session-3 CSIT221 Spring 2003 b Group Worksheet 3 Exercise (Demo Required) b No new lab demo will be assigned to allow you to focus on HW#1.
Introduction to Computing Dr. Nadeem A Khan. Lecture 24.
Software and Software Vulnerabilities. Synopsis Array overflows Stack overflows String problems Pointer clobbering. Dynamic memory management Integer.
© The McGraw-Hill Companies, 2006 Chapter 5 Arrays.
Chapter 71 Array Properties Upper Bound: The value of arrayName.GetUpperBound(0) is the upper bound of arrayName(). Then What is the Lower Bound ? Ans:
Chapter seven review. What is the output of: Private Sub cmdButton_Click() Dim i As Integer, a(1 To 4) As integer Open "DATA.TXT" For Input As #1 For.
Chapter 41 Sub Procedures, Part II (Continue). Chapter 42 Local Variable A variable declared inside a Sub procedure with a Dim statement Space reserved.
Chapter 31 Fundamentals of Programming in VB(Continue I) Numbers Arithmetic Operations Variables Incrementing the Value of a Variable.
Introduction to Computing Dr. Nadeem A Khan. Lecture 5.
Chapter 51 Select Case block A decision-making structure that simplifies choosing among several actions. Avoids complex nested If constructs. If blocks.
A Level Computing#BristolMet Session Objectives U2#S6 MUST identify different data types used in programming aka variable types SHOULD describe each data.
IE 212: Computational Methods for Industrial Engineering
Copyright © 2001 by Wiley. All rights reserved. Chapter 12: Programmer- Defined Types, Direct Access Files, and Object Classes Programmer Defined Data.
Chapter 17: Arrays Spreadsheet-Based Decision Support Systems Prof. Name Position (123) University Name.
Microsoft Access Using Visual Basic Routines. Visual Basic Datatypes Boolean Byte Currency Date Double Integer Long Object Single String Variant Hyperlink.
STRINGS & STRING HANDLING FUNCTIONS STRINGS & STRING HANDLING FUNCTIONS.
Comp 248 Introduction to Programming Chapter 6 Arrays Part B Dr. Aiman Hanna Department of Computer Science & Software Engineering Concordia University,
Arrays and 2D Arrays.  A Variable Array stores a set of variables that each have the same name and are all of the same type.  Member/Element – variable.
19/10/20151 Data Structures Arrays. 219/10/2015 Learning Objectives Explain initialising arrays and reading data into arrays. Design and write routine/s.
Arrays Module 6. Objectives Nature and purpose of an array Using arrays in Java programs Methods with array parameter Methods that return an array Array.
Array - adding to array at run time Please see speaker notes for additional information!
# 1# 1 Searching andSorting What is selection sort? What is bubble sort? What is binary search? CS 105 Spring 2010.
Chapter 7 - VB 2008 by Schneider1 Chapter 7 – Arrays 7.1 Creating and Accessing Arrays 7.2 Using Arrays 7.3 Some Additional Types of Arrays 7.4 Sorting.
1 Chapter 7 – Arrays 7.1 Creating and Accessing Arrays 7.2 Using Arrays 7.3 Some Additional Types of Arrays 7.4 Sorting and Searching 7.5 Two-Dimensional.
Random Files Please see speaker notes for additional information!
Arrays1 From time to time an object (a variable, a picture, a label or a command) does not serve as well as a set of objects of a similar kind addressed.
MIS 216 Exam1 Review Spring What to expect Questions like those on the home works and on the quizzes Evaluate code Create code Multiple choice and.
CSC 162 Visual Basic I Programming. Array Parameters and Sorting Array Parameters –Entire Arrays –Individual Elements Sorting –Bubble Sort.
The PC GadgetMaster II Stepper Motor Control Developed by Frank Shapleigh Edited by Jim Tuff.
Programming Logic and Design Fourth Edition, Comprehensive Chapter 8 Arrays.
Chapter 71 Arrays Creating and Accessing Arrays Using Arrays Some Additional Types of Arrays.
PSU CS 106 Computing Fundamentals II VB Declarations HM 5/4/2008.
Lec 21 More Fun with Arrays: For Loops. Agenda Some backfill for Lab 20: – Using an array in an applet or class – array instance variables – using Math.random()
IS2802 Introduction to Multimedia Applications for Business Lecture 4: JavaScript, Loops, and Conditional Statements Rob Gleasure
05/02/ Records. 205/02/2016 Learning Objectives State: The difference between records and arrays. The difference between records and arrays. How.
CHAPTER EIGHT ARRAYS © Prepared By: Razif Razali1.
Chapter 7 - VB.Net by Schneider1 Chapter 7 – Arrays 7.1 Creating and Accessing Arrays 7.2 Using Arrays 7.3 Some Additional Types of Arrays 7.4 Sorting.
1 Chapter 7 Arrays. 2 Outline and Objective In this chapter we will Learn about arrays One-dimensional arrays Two-dimensional arrays Learn about searching.
Topic: Control Statements. Recap of Sequence Control Structure Write a program that accepts the basic salary and allowance amount for an employee and.
A club in Leicester holds exclusive after party sessions for members only. In order to get into one of the after parties you need to be “on the list”.
Arrays (part 2) 1 -Based on slides from Deitel & Associates, Inc. - Revised by T. A. Yang.
Fourth Quarter.  Involves loops or cycles ◦ Loops: means that a process may be repeated as long as certain condition remains true or remains false. ◦
1 Applied Arrays Lists and Strings Chapter 12 2 Applying What You Learn Searching through arrays efficiently Sorting arrays Using character arrays as.
CSC 162 Visual Basic I Programming. Storage Classes Determines the “lifetime” of an identifier Types: –Automatic Default Memory is allocated for the variable.
Visual Basic CDA College Paphos Campus COM123 Visual Programming 1 Lecture: Charalambous Sotiris Week 8: COM123 Visual Programming 1 Lecture: Charalambous.
Ch. 101 DataTable (Continue) Lab sheet 10.3: Form Display Cities table along with percentage growth.
Dani Vainstein1 VBScript Session 5. Dani Vainstein2 What we learn last session? Branching Branching using If … Then … Else statement. Branching using.
VISUAL C++ PROGRAMMING: CONCEPTS AND PROJECTS Chapter 7A Arrays (Concepts)
Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 19 A Ray of Sunshine.
Chapter 7 - VB 2005 by Schneider1 Chapter 7 – Arrays 7.1 Creating and Accessing Arrays 7.1 (a) Arrays and Loops 7.2 Using Arrays 7.3 Some Additional Types.
Introduction to programming in java Lecture 21 Arrays – Part 1.
Processing multiple files
UMBC CMSC 104 – Section 01, Fall 2016
Object Oriented Programming in java
Language Constructs Construct means to build or put together. Language constructs refers to those parts which make up a high level programming language.
Chapter 7 - VB.Net by Schneider
Lec 21 More Fun with Arrays: For Loops
Presentation transcript:

Chapter 71 Using Part of an Array Sometimes we do not know how many elements will be needed in an array. We can declare a large array, say of 100 elements, and use a counter variable to record the number of elements used. In this example, the names are an unknown number of companies is placed into an array.

Chapter 72 Lab sheet 7.3: Output In this example, you are required to build a program which stores the company name in a pre-defined array using a Counter Variable. Please refer to lab sheet for detail Instruction.

Chapter 73 Lab sheet 7.3: Stocks Refer to Lab Sheet 7.3 For Detail In the Program, variable “Counter” is a kind of Counter variable which count the usage of the array. By referencing the counter variable, we can easily know the usage of the array.

Chapter 74 Lab sheet 7.3: Code 'Demonstrate using part of an array Dim stock(99) As String Dim counter As Integer Private Sub btnRecord_Click(...) Handles btnRecord.Click If (counter < 99) Then stock(counter) = txtCompany.Text counter += 1 'Increment counter by 1 txtCompany.Clear() txtCompany.Focus() txtNumber.Text = CStr(counter) Else MsgBox("No space to record additional companies.", 0, "") txtCompany.Clear() End If End Sub

Chapter 75 Lab sheet 7.3: Code Continued Private Sub btnSummarize_Click(...) _ Handles btnSummarize.Click 'List companies that were recorded lstStocks.Items.Clear() For i As Integer = 0 To counter - 1 lstStocks.Items.Add(stock(i)) Next End Sub Since the first element of an array is (0), the total number of element of array should be (counter-1)

Chapter 76 Ordered Arrays An array has ascending order if [each element] ≤ [next element]. An array has descending order if [each element] ≥ [next element]. An array is ordered if it has ascending or descending order.

Chapter 77 Searching Ordered Arrays Ordered arrays can be searched more efficiently than unordered arrays. For instance, when searching an array having ascending order, you can terminate the search when you find an element whose value is ≥ the sought- after value.