0% found this document useful (0 votes)
2 views

Array Processing- Updated

The document provides an introduction to arrays, explaining their data types, memory allocation, and operations. It covers one-dimensional and multi-dimensional arrays, including algorithms for storing, searching, updating, and performing calculations on array elements. Additionally, it includes examples and pseudocode for practical applications involving arrays, such as calculating totals and averages, and finding the largest and smallest values.

Uploaded by

susebstein
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Array Processing- Updated

The document provides an introduction to arrays, explaining their data types, memory allocation, and operations. It covers one-dimensional and multi-dimensional arrays, including algorithms for storing, searching, updating, and performing calculations on array elements. Additionally, it includes examples and pseudocode for practical applications involving arrays, such as calculating totals and averages, and finding the largest and smallest values.

Uploaded by

susebstein
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 35

Arrays Introduction

Data type
It type of data a variable can hold or the type of value
Examples
1. A b c 123 &$$ ( Characters)
2. 12 , 10 , 30, (Integers)
3. 12.5 , 1.788990 , 4.56 (Double)
4. Sam, name ,(Strings)
5. True, false (Boolean )
Variable – A memory location that contains a value that can change at any time
An array is a data structure that holds data that has the same data
type.
Understanding Arrays and How They
Occupy Computer Memory
• Array
• Series or list of variables in computer memory
• All variables share the same name
• Each variable has a different subscript(Position)
• Subscript (or index)
• Position number of an item in an array
• Subscripts are always a sequence of integers
1. Name
Example – an array to hold 5 numbers
number = Array[5]
number[0] = 6
number[1] = 45
number[4] = 66

6 45 100 20 66
Programming Logic & Design, Sixth Edition 2
Arrays
AND OPERATIONS ON ARRAYS
How Arrays Occupy
Computer Memory
• Each item has same name and same data type
• Element: an item in the array
• Array elements are contiguous in memory(come one after the other)
• Size of the array: number of elements it will hold

Programming Logic & Design, Sixth Edition 4


The Operations on Arrays
1. Capture (Store in Array)√
2. Display the values √
3. Perform Calculations √
4. Search √
5. Update √
6. Reverse the order and Display √
7. Sort and display
8. Delete
9. Smallest number √
10. Largest number √
One Dimensional Array
Types Of arrays
1. One Dimensional
2. Multi- Dimensional
a. Two or more dimensional
b. Jaggered
ONE D
- One direction – row (Horizontal)
- Column (Vertical)
Arrays – Declaration and Storage
A.
Important Thing about Arrays
1. Size of an array – Is the number of elements in
the array e.g. 1D ARRAY – 9,
The size of Numbers – 5
B. Numbers 2. Index / Position/ Subscript – This is were you
find the different elements starts at 0 and ends at
(size – 1 )
What is at index 7 in D.? = 44
What is at index 0 in D. ? = 35
3. Declaration an Array – To use an it should
ALWAYS be declared first
Example
A. Characters = Array[9]
B. Nums = Array[5]
C.

D.
Example 1
Write an Algorithm using pseudocode of an application that takes 5 numbers
stores them in an array. The program then adds the numbers together for a total,
calculates average and displays the numbers, the total and the average to the
screen.
Input Processing Output
number 1. Declare Array Number x 5
2. LoopX 5 Total
a. Promp for number Average
b. Get number
c. Store number in an array
3. Loop x 5
a. Calculate total = total + (Elements
Postion 0 to 4 )
4. Calculate Average = total/5
5. Loop x 5
a. Display position 0 to 4
6. Diplay Total
7. Display Average
Solution Algorithm
Processing Solution Algorithm
1. Declare Array 1. Start
2. LoopX 5 2. Number = Array[5], total = 0, average = 0.00 //Declaration
a. Promp for number 3. For(x = 0; x< 5 ; x++)
b. Get number 4. Display “ Give me a number)
c. Store number in an array 5. Numbers[x] = get value
3. Loop x 5 6. EndFor
a. Calculate total = total + (Elements Postion 0 to 4 ) 7. For(x = 0; x< 5 ; x++)
4. Calculate Average = total/5 8. total = total + Number[x]
5. Loop x 5 9. EndFor
a. Display position 0 to 4 10. average = total/Numbers.Length // You can use 5 also
6. Diplay Total 11. For(x = 0; x< 5 ; x++)
7. Display Average 12. Display Number[x]
13. EndFor
14. Display total, average
15. End
Searching and Updating
Searching – finding a value in an array
Updating – Changing to a new value
Write an algorithm using pseudocode of a program that takes 10 names from the
keyboard and does the following :
1. Store in an Array
2. Search if the name Sinazo is in the array and display the index/ position of the
name
3. Search if the name James is in the array and replace it with Jimmy.
4. Search it the name Sussy is in the array and replace with a value from the user
Input Processing Output
name 1. Declare Array positionOFSinazo
2. LoopX 10
a. Promp for name
b. Get name
c. Store name in an array
3. Loop x 10
a. Check IF(Sinazo == Position 0 – 9)
b. Display position
c. Check IF(James == Position 0 – 9)
d. Replace James with Jimmy
e. Check IF (Sussy == Position 0- 9)
f. Repalce with get value from user

4. Display message not found


Processing Solution Algorithm
1. Declare Array 1. Start
2. LoopX 10 2. Names = Array[10]
a. Promp for name 3. For(n = 0; n < 10 ; n++)
b. Get name 4. Display “ Enter Name”
c. Store name in an array 5. Names[n] = get Value
3. Loop x 10 6. End For
a. Check IF(Sinazo == Position 0 – 9) 7. sinazoFound = False
i. Display position 8. For(n = 0; n < 10 ; n++)
b. Check IF(James == Position 0 – 9) 9. If( Names[n] == “Sinazo”)
c. Replace(Update) James with Jimmy 10. Display “ The name Sinazo is at position:” + n
d. Check IF (Sussy == Position 0- 9) 11. sinazoFound = True
e. Replace(Update) with get value 12. EndIF
from user 13. If( Names[n] == “James”)
14. Names[n] = “Jimmy”
4. Display message not found 15. EndIF
16. If( Names[n] == “Sussy”)
17. Display “ Enter name to replace sussy”
18. Names[n] = get value
19. EndIF
20. EndFor
21. If (sinazoFound == False)
22. Display “The name Sinazo is not in the Array”
23. EndIF
24. END
Names
Asanda Sinazo Trump Biden Nolly Blondy James Issa Sussy Peter
Position n = 0 1 2 3 4 5 6 7 8 9

Value of n Condition (T/F) Array Values 1. Start


0 0<10 – True Names[0] = “Asanda” 2. Names = Array[10]
3. For(n = 0; n < 10 ; n++)
1 1< 10 - True Names[1] = “Sinazo” 4. Display “ Enter Name”
2 2<10 - True Names[2] = “Trump” 5. Names[n] = get Value
6. End For
3 3< 10 – True Names[3] = “Biden” 7. sinazoFound = False
. 8. For(n = 0; n < 10 ; n++)
. 9. If( Names[n] == “Sinazo”) // Search
10. Display “ The name Sinazo is at position:” +
9 9< 10 - True Names[9] = “Peter” n
11. sinazoFound = True
12. EndIF
Enter Name 13. If( Names[n] == “James”)
Asanda 14. Names[n] = “Jimmy”
Enter Name 15. EndIF
Sinazo 16. If( Names[n] == “Sussy”)
Enter Name
17. Display “ Enter name to replace sussy”
18. Names[n] = get value
Trump 19. EndIF
Enter Name 20. EndFor
Biden 21. If (sinazoFound == False)
22. Display “The name Sinazo is not in the Array”
23. EndIF
24. END
Names
Asanda Sinazo Trump Biden Nolly Blondy Jimmy Issa Sussy Peter
0 1 2 3 4 5 6 7 8 9

1. Start
2. Names = Array[10]
Value of n Condition (T/F) If Condition 3. For(n = 0; n < 10 ; n++)
0 0<10 – True Names[0] == “Sinazo” 4. Display “ Enter Name”
=> “Asanda” == “Sinazo” – False 5. Names[n] = get Value
6. End For
1 1< 10 - True Names[1] == “Sinazo” 7. sinazoFound = False
=> “Sinazo” == “Sinazo” – True 8. For(n = 0; n < 10 ; n++)
9. If( Names[n] == “Sinazo”) // Search
2 2<10 - True 10. Display “ The name Sinazo is at position:” + n
3 3< 10 – True 11. sinazoFound = True
12. EndIF
. 13. If( Names[n] == “James”)
. 14. Names[n] = “Jimmy”
9 name Sinazo
9< 10 - True 15. EndIF
The is at position : 1 16. If( Names[n] == “Sussy”)
17. Display “ Enter name to replace sussy”
18. Names[n] = get value
Names[6] = “Jimmy” 19. EndIF
20. EndFor
21. If (sinazoFound == False)
22. Display “The name Sinazo is not in the Array”
23. EndIF
24. END
Reversing , Biggest and Smallest
Reversing – is displaying the array stating with what is on the last position to
position 0
Biggest is comparing the values in the array and display biggest value
Smallest is comparing the values in the array and displaying the smallest
Write an Algorithm using pseudocode, flowchart of a program that takes the ages
of 15 babies in a nursery school and does the
1. Stores in an Array
2. Reverse and Displays
3. Displays the Oldest(Biggest)
4. Displays the Youngest(Smallest)
Input Processing Output
age 1. Declare Array Ages in reverse
2. LoopX 15(Storage) Oldest
a. Promp for age Youngest
b. Get age Biggest = Ages[0]
c. Store age in an array If(Biggest < Ages[x])
3. Loop x 15(Reverse) Biggest = Ages[x]]
a. Display from Position 14 to 0
4. Assign first element to the biggest variable
– biggest = What is in Position 0
5. Loop x 15(Biggest)
a. Compare IF biggest is < than what is in
current position
a. Make current Position the biggest
6. Assign first element to the biggest variable
– smallest = What is in Position 0

7. Loop x 15(Smallest)
a. Compare IF smallest is > than what is
in current position
a. Make current Position the biggest

100 20 15 200 3 4 5 21 100 56 44 34 44 20 33


0 1 2 3 4 5 6 7 8 9 10 11 12 13 14
1. Declare Array 1. Start
2. LoopX 15(Storage) 2. AgesOfBabies = Array[15]
a. Promp for age 3. For(y = 0; y < 15 ; y++)
b. Get age 4. Display “ Age of baby”
c. Store age in an array 5. AgesOfBabies [y] = get value
3. Loop x 15(Reverse) 6. EndFor
a. Display from Position 14 to 0 7. For(y = 15; y > 0 ; y--) // Reversing
4. Assign first element to the biggest variable –
8. Display AgesOfBabies [y]
biggest = What is in Position 0 9. EndFor
5. Loop x 15(Biggest) 10. Biggest = AgesOfBabies [0]
a. Compare IF biggest is < than what is in 11. For(y = 0; y < 15 ; y++) //Biggest
current position 12. If(Biggest < AgesOfBabies [y] )
a. Make current Position the biggest 13. Biggest = AgesOfBabies [y]
6. Assign first element to the biggest variable –
14. EndIF
smallest = What is in Position 0 15. EndFor
16. smallest = AgesOfBabies [0]
7. Loop x 15(Smallest) 17. For(y = 0; y < 15 ; y++)// Smallest
a. Compare IF smallest is > than what is in 18. If(smallest > AgesOfBabies [y] )
current position 19. smallest = AgesOfBabies [y]
a. Make current Position the biggest 20. EndIF
21. EndFor
22. Display “ The Oldest is : “ + biggest
23. Display “ The Youngest Is:” + smallest
24. End
Homework Arrays (Please Do the IPO –
Flowchart and share with me on teams)
A. Write an algorithm using pseudocode, flowchart of an application that takes
the salary of 25 lecturers at University of Pretoria and does the following:
1. Stores in an Array
2. Display the most paid
3. Display the least paid
4. Display the Average salary
5. Update the salary by 5% of all those with a salary less than 10 000
B. Write Pseudocode and draw flowchart of an algorithm that captures the names
of 100 products from TM supermarket. The program should then do the
following
1. Stores in an Array
2. Display all names
3. Reverse and display
4. Search if “Chicken” is in the array and display is index/position.
Sorting and Deleting
Sorting – This is when you change the order of the values in the
array to place them ascending OR descending
Ascending (Smallest to Biggest)
A- Z
A–1 Value y Value y+1 IF(Condition T/F)
Z – 26 0 1 500>300? T
Descending(Biggest to Smallest) 1 2 500 > 1 ? T
Z –A 2 3 500>200? T
The Sorting Operation 3 4 500> 10? T
1. Needs a Temporary Variable to help with Swapping
For (x = 0; x < 5; x++)
2. The contents compared and the swapped For (y=0; y < 4 : y++) Compare and Swap
IF(Numbers[y] > Numbers[y+ 1])
Sorted Array(Ascending) temp = Numbers[y]
Numbers[y] = Number[y+1]
Numbers[y+1] = temp
EndIF
Numbers EndFor
300 1 200 10 500 temp
0 1 2 3 4 500
S
Sorting Example
Write an algorithm using pseudocode and draw a flowchart of an application that
takes the ages of 10 of your classmates and sorts it in Descending order. The
application should also check if there is anyone who is 18 years and remove
them from the array.
Input Processing Output
Age 1. Declare Array Age size 10 Age (from oldest –
2. LoopX10 (STORE) younget)
a. Prompt for age
b. Get age
c. Store in the array
3. Loop X 10 (SORT)
a. Loop X 10
i. Compare
ii. Swap
4. Loop X 10 (DELETE)
a. Search
b. If (Check Position 0 to 9 == 18)
a. True - Remove
Processing Solution Algorithm
1. Declare Array Age size 10 1. Start
2. LoopX10 (STORE) 2. studentAges = Array[10] temp = 0// Declaration
a. Prompt for age 3. For(v = 0; v < 10 ; v++) // STORE
b. Get age 4. Display “ Ask for Age”
c. Store in the array 5. studentAges[v] = get value
3. Loop X 10 (SORT) 6. EndFor
a. Loop X 10 7. For(u = 0; u < 10 ; u++) // SORT
i. Compare 8. For(y = 0; y < 9 ; y++) // Comparing and Swapping
ii. Swap 9. If(studentAges[y]> studentAges[y+1] // Compare
4. Loop X 10 (DELETE) 10. temp = studentAges[y]
a. Search 11. studentAges[y] = studentAges[y + 1]
b. If (Found ) 12. studentAges[y+ 1] = temp
a. True - Remove 13. EndIF
14. EndFor
15. EndFor
16. For(u = 0; u < 10 ; u++) // Display Sorted Array
17. Display studentAges[u]
18. EndFor
19. For(u = 0; u < 10 ; u++) // DELETE
20. If(studentAges[u] == 18)
21. studentAges[u] = “ “
22. EndIF
23. EndFor
24. END
Flowchart
1. Start Terminal Symbol
2. studentAges = Array[10] temp = 0// Declaration Process
3. For(v = 0; v < 10 ; v++) // STORE Loop
4. Display “ Ask for Age” Output
5. studentAges[v] = get value Input
6. EndFor
7. For(u = 0; u < 10 ; u++) // SORT Loop
8. For(y = 0; y < 9 ; y++) // Comparing and Swapping loop
9. If(studentAges[y]> studentAges[y+1] // Compare
10. temp = studentAges[y] //Process
11. studentAges[y] = studentAges[y + 1] //Process
12. studentAges[y+ 1] = temp //Process
13. EndIF
14. EndFor
15. EndFor
16. For(u = 0; u < 10 ; u++) // Display Sorted Array
17. Display studentAges[u]
18. EndFor
19. For(u = 0; u < 10 ; u++) // DELETE
20. If(studentAges[u] == 18)
21. studentAges[u] = “ “
22. EndIF
23. EndFor
24. END
Exam and Test Tip
1. Theory – Everything
a. Digital Logic – Arrays
2. Algorithms using Pseudocode / Flowchart
a. Control Structures
b. Sequence
c. Selection(All Types of IF)
i. IF(ALL)
ii. CASE
iii. MENU
d. Loop
i. While
i. Counted(incrementing and decrementing)
ii. Stop value
ii. For
i. Counted(incrementing and decrementing)
e. Arrays Different Operations
i. Store
ii. Calculate
iii. Display
iv. Search
v. Update
vi. Delete
vii. Sort
viii. Biggest
ix. Smallest
x. Reversing
1. Start
2. Marks = Array[100], choice = 0
Menu Example 3. Display “ 1. Capture”
4. Display “ 2. Display Marks ”
Write an algorithm using pseudocode and 5. Display “ 3. Display Highest”
draw a flowchart of a menu driven 6. Display “ 4. Exit”
application that takes 100 marks of 7. Display “ Make a choice from above menu”
programming test marks and does the 8. Choice = get value
following. 9. Switch (choice)
A. Display the following Menu 10. Case 1 :
11. For(x= 0; x < 100 ; x++) // Store
1. Capture Marks 12. Display “Enter mark”
2. Display Marks 13. Marks[x] = get value
3. Display The best Mark 14. EndFor
15. Break
4. Exit Application
16. Case 2:
B. For (1)- Store in Array 17. For(x= 0; x < 100 ; x++) // Display
18. Display Marks [x]
C. For (2) – Display the Marks 19. EndFor
D. For (3) – Display the highest Mark 20. Break
21. Case 3
22. highest = Marks[0]
23. For(x= 0; x < 100 ; x++) // Biggest
24. IF(highest < Marks [x]
25. highest = Marks[x]
26. EndIF
27. EndFor
28. Break
Operations On Arrays
Write an algorithm using pseudocode of an application that gets ages of 5 primary
school children and stores them in an array. Your application should be menu driven
and have the following options and functionality:
1. Capture

Step 1 Start
Step 2 children = Array[5]
Step 3 stop = ‘ ’
Step 4 While(stop !=‘z’)
Step 5 Display “1. Capture”
Step 6 Display “2. Display”
Step 7 Display “Make a choice from the above menu”
Step 8 option = 0
Step 9 option = get value
Step 10 Switch(option)
Step 11 Case 1
Step 12
Operations On Arrays
Write an algorithm using pseudocode of an application
that gets ages of 5 primary school children and stores
7 12 8 5 9 them in an array. Your application should be menu driven
and have the following options and functionality:
0 1 2 3 4 1. Capture

Step 1 Start
x Condition Array Step 2 stop = ‘ ’
Position Step 3 While(stop !=‘z’)
Step For( x=0; x<5;x++)//x = x +1
0 true children[0] 13 children[x] = get value
Step EndFor
Break
1 true children[1] 14 Case 2
Step
2 true children[2] 15
3 true Step
16
Step
17
Step
18
Step
Operations On Arrays
Write an algorithm using pseudocode of
7 12 8 5 9 application that gets ages of 5 primary school
children and stores them in an array. Your
0 1 2 3 4 application should be menu driven and have
the following options and functionality:
2. Display the ages
Output
7 12 8 5 9 Step 1 Case 2
Step 2 For( x=0; x<5;x++)//x = x +1
Step 3 Display children[x]
Step 4 break EndFor
Step 5
Step 6
Step 1
Step 1
Step 1
Step 1
Step 1
Operations On Arrays
Write an algorithm using pseudocode of
7 12 8 5 9 application that gets ages of 5 primary school
children and stores them in an array. Your
0 1 2 3 4 application should be menu driven and have
the following options and functionality:
3. Reverse and display
Output
9 5 8 12 7 Step 1 Case 3
Step 2 For( x=4; x>=0;x--)//x = x -1
Step 3 Diplay children[x]
Step 4 EndFor
Step 5 break
Step 6
Step 1
Step 1
Step 1
Step 1
Step 1
Operations On Arrays
Write an algorithm using pseudocode of application that
4 7 5 8 9 gets ages of 5 primary school children and stores them
in an array. Your application should be menu driven and
have the following options and functionality:
0 1 2 3 4 4. Sort

Step 1 Case 4
Step 2 temp = 0
Step 3 For( x=0; x<5;x++)//x = x +1
temp Step 4 For( y=0; y<4;y++)//y= y+1
Step 5 If(children[y]>children[y+1]
//Swap
Output Step 6 temp = children[y]
45789 Step 1 children[y] = children[y+1]
Step 1 children[y+1] = temp
Step 1 EndIf
Step 1 EndFor
Step 1 EndFor
Operations On Arrays
Write an algorithm using pseudocode of application that gets ages of 5
primary school children and stores them in an array. Your application
should be menu driven and have the following options and functionality:
5. Search and : Step 1 Case 5 :
a. Update Step 2 age = 0
b. Delete Step 3 Display “ enter the age to be updated”
Step 4 age = get value
Step 5 For( x=0; x<=4;x++)//x = x +1
Step 6 If( age == children[x])
Step 10 children[x] = children[x] + 3
Output Step 11 Display “Age updated to” children[x]
Age updated to Step 12 EndIF
Step 13 EndFor
Step 14 For( x=0; x<=4;x++)//x = x +1
If( age == children[x])
children[x] = “ “
Display “Record deleted”
EndIF
EndFor
break
Operations On Arrays
Write an algorithm using pseudocode of application that gets ages of 5 primary
school children and stores them in an array. Your application should be menu
driven and have the following options and functionality:
6. Oldest
Step 1 Case 6 :
Output Step 2 largest = children[0]
12 Step 3 For( x=0; x<=4;x++)//x = x +1
Step 4 If( largest < children[x])//children[x]>largest
Step 5 largest = children[x]
EndIF
Step 6 EndFor
Step 1 Display largest
Step 1 break
Step 1
Step 1
Step 1
Operations On Arrays
Write an algorithm using pseudocode of application that gets ages of 5
primary school children and stores them in an array. Your application
should be menu driven and have the following options and
functionality: Step 1 Case 7:
7. Youngest Step 2 youngest = children[0]
Step 3 For( x=0; x<=4;x++)//x = x +1
Step 4 If( youngest > children[x])//children[x]< youngest
Step 5 youngest = children[x]
Step 6 EndIF
Step 1 EndFor
Output Step 1 Display youngest
4 Step 1 Break
Step 1 Case 8:
Step 1 End //Ends program
Default:
Display “wrong choice choose correct option from the
given menu”
Display “ type ‘z’ to stop any character to proceed “
stop = get value
EndWhile
Two Dimensional Array
01 Eva 100000 Write an Algorithm using pseudocode of a program that asks for the employee number, name and salary of 5
employees. The application should be menu drive and have the following options that the user can choose fr
0 Provide functionality for each option and ensure that the program repeats until the user wants to exit. The o
are a follows:
02 Sussy 1200 1. Capture Details
2. Display all Employees
3. Sort according to most paid

Step 1 Start
x Array Step 2 employee[5,3]
Condition Position Step 3 For( x=0; x<5;x++)//x = x +1
Step 4 Diplay “Input Employee No”
0 true employee[0,0] Step 5 employee[x,0] = get value
employee[0,1] Diplay “Input name”
Step 6 employee[x,1] = get value
employee[0,2]
Step 1 Diplay “Input Salary”
Step 1 employee[x,2] = get value
Step 1 EndFor
1 true employee[1,0]
Step 1
employee[1,1]
employee[1,2] Step 1
Two Dimensional Array
01 Eva 100000 Write an Algorithm using pseudocode of a program that asks for the employee number, name and salary of 5
employees. The application should be menu drive and have the following options that the user can choose fr
0 Provide functionality for each option and ensure that the program repeats until the user wants to exit. The o
are a follows:
02 Sussy 1200 1. Capture Details
2. Display all Employees
3. Sort according to most paid

Step 1 Start
Step 2 employee[5,3]
Step 3 For( x=0; x<5;x++)//x = x +1
Step 4 Display employee[x,0]
Step 5 Diplay employee[x,1]
Diplay employee[x,2]
Step 6 EndFor
Step 1
Step 1
Step 1
Step 1
Step 1
Two Dimensional Array
Write an Algorithm using pseudocode of a program that asks for the employee number, name and
salary of 5 employees. The application should be menu drive and have the following options that the
01 Eva 100000 user can choose from. Provide functionality for each option and ensure that the program repeats
0 until the user wants to exit. The options are a follows:
1. Capture Details
02 Sussy 1200 2. Display all Employees
3. Sort according to most paid

Step 1 Start
Step 2 employee[5,3]
Step 3 tempSalay = 0.00
Step 4 tempName = “ “
Step 5 tempEmpNo = 0
Step 6 For( y=0; y<5;y++)//y = y +1
Step 1 For( x=0; x<5;x++)//x = x +1
Step 1 If(employee[x,2] < employee[x +1 ,2])
Step 1 tempSalary = employee[x,2]
Step 1 employee[x,2] = employee[x +1 ,2]
Step 1 employee[x +1 ,2] = tempSalary

tempName = employee[x,1]
employee[x,1] = employee[x +1 ,1]
employee[x +1 ,1] = tempName

tempEmpNo = employee[x,0]
employee[x,0] = employee[x +1 ,0]
employee[x +1 ,0] = tempEmpNo
EndIF
EndFor
EndFor

You might also like