CSCI 150, Spring 2003
Home | | Course Schedule | | Assignments | | Lecture NotesLab 4 solution
{program: find.pas Author: Brenda Student Class: CSCI 150, Section 03 Date: 2/12/03 Assignment: Lab 4 Purpose: Find a number in a list of numbers.} program storeAndFind; type listType = array[1..10] of integer; var list: listType; {Array to hold the list of numbers} count: integer; {counter for the loops} number: integer; {number to search for} found: boolean; {indicates whether number was found in the list} begin writeln('Please enter ten integers separated by a space.'); for count := 1 to 10 do begin read(list[count]); end; writeln('Please enter a number to search for: '); readln(number); found := false; for count := 1 to 10 do begin if list[count] = number then begin found := true; end; end; if found then begin writeln('The number ', number, ' was found in the list.'); end else begin writeln('The number ', number, ' was not found in the list.'); end; end.