C155-111611-Chap8ArraysSearch

C155-111611-Chap8ArraysSearch - CPT 155 Introduction to...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
CPT 155  Introduction to Object-Oriented  Programming Objectives: 1. Search arrays Assignments 1. Read Chapter 9 2. Lab 10 due Monday night CNIT 15500, Fall 2011 © 2011, Alka Harriger  Slide1
Background image of page 1

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

View Full DocumentRight Arrow Icon
CNIT 15500, Fall 2011 © 2011, Alka Harriger  Slide2 Adding to the end of the array Use last location variable as index location for array to add data mNbr[mLastLoc] = int.Parse(txtNbr.Text); mName[mLastLoc] = txtName.Text; Add one to the last location variable mLastLoc++; Searching for a value in the array Keep track of match found or not Search from one end of the array until a match is found or you reach the end If match found, show related information If not found, show an appropriate message
Background image of page 2
CNIT 15500, Fall 2011 © 2011, Alka Harriger  Slide3 // assume searchVal has the value you are seeking bool found = false; // tracks whether search value has been found index = 0; // start with the first location
Background image of page 3

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

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 02/21/2012 for the course CIT 155 taught by Professor Lutes during the Fall '10 term at Purdue University-West Lafayette.

Page1 / 7

C155-111611-Chap8ArraysSearch - CPT 155 Introduction to...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online