{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Simple Array Process

Simple Array Process - Read inputNum if inputNum<> 0...

This preview shows pages 1–3. Sign up to view the full content.

Process: 1. Prompt the user to enter integer numbers other than 0 (zero), one at a time, with a maximum of 100 numbers into the array Numbers. 2. Prompt the user to enter 0 (zero) when he or she wants to quit. 3. Do not store zero. 4. Sort the list of numbers using a bubble sort. 5. Print the first element as the smallest number. 6. Print the last element as the largest number. Input: List of numbers (integer: Numbers[1. .100]) Output: Smallest number (integer: minNum) Largest number (integer: maxNum) Pseudocode Main Module Declare Numbers[100] as integers Declare minNum as integer Declare maxNum as integer Declare listCount as integer Declare inputNum as integer Call Input Data Module Call Sort Numbers Module Call Find Minimum Module Call Find Maximum Module Call Print Results Module End Main Module Input Data Module Display "Please enter integer numbers other than 0" Display "Enter 0 (zero) to stop processing numbers" Set listCount = 0 Set inputNum = 1 While listCount <= 100 AND inputNum <> 0 Display "Enter Number: "

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Read inputNum if inputNum <> 0 Set listCount = listCount + 1 Set Numbers[listCount] = inputNum end if end while End Data Module Sort Numbers Module Declare flag as integer Declare k as integer Declare temp as integer Set flag = 0 Set count = 0 While flag = 0 set flag = 1 for k = 1 step 1 to listCount if Numbers[k] > Numbers[k + 1] then Set temp = Numbers[k] Set Numbers[k] = Numbers[k + 1] Set Numbers[k + 1] = temp Set Flag = 0 end if end for End While End Sort Numbers Module Find Minimum Module if listCount >= 1 then minNum = Numbers[1] else minNum = 0 end if End Find Minimum Module Find Maximum Module if listCount > =1 AND listCount <= 100 then maxNum = Numbers[listCount] else maxNum = 0 end if End Find Maximum Module Print Results Module if listCount >= 1 then Display "The smallest number is: " Write minNum Display "The largest number is: " Write maxNum else Display "There are no numbers in the list" end if End Print Results Module...
View Full Document

{[ snackBarMessage ]}

Page1 / 3

Simple Array Process - Read inputNum if inputNum<> 0...

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

View Full Document
Ask a homework question - tutors are online