University Project: Using Files

profilemaeae9
AbeytaMeganPRG211week4.docx

University Project: Using Arrays

Megan Abeyta

PRG/211

Prof. Bary Pollack

University of Phoenix

November 19, 2018

Pseudocode

array is an 2D Array of length=size used to store multiple credit card numbers

Initialize num to zero

Initialize found to -1

Print Request to Enter Credit Card Number

Input the number in num

Initialize loop variable i to zero

//Start while loop

WHILE i<size

IF num is equal to array[i]

Set found to i

break;

ELSE

i++

ENDIF

ENDWHILE

//While loop ended

IF found is zero

Print invalid message

"Number not found"

ELSE

Print valid message

"Credit Card Number Found"

Pseudocode is a detailed description of what a specific program should do and in what sequence it should be done. During coding, pseudocode helps a programmer as a guide informing how the program should run. The pseudocode written above describes how a program searches a credit card number in an array and display the result accordingly.

Flowchart

Flowchart is the diagrammatic representation of how program should work. It is a combination of steps who show the purpose and flow of a source code. The flowchart below describes the working of the pseudocode mentioned above. It shows the working of while loop and IF inside loop and IF/ELSE after the loop.

START

num=0

found=0

INPUT num

i=0

WHILE i<size

num==array[i]

found=i

i++

found==0

OUTPUT invalid

OUTPUT valid

END

END WHILE

T

F

F

T

T

Bibliography Gary Pollice, S. S. (July 2009). Algorithms in a nutshell. O'Reilly Media. Wirth, N. (1976). Algorithms + Data Structures = Programs. Zurich: Prentice-Hall.