0% found this document useful (0 votes)
20 views1 page

Homework

Uploaded by

web86598
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views1 page

Homework

Uploaded by

web86598
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Step 1: Declare the array

MAX_LENGTH is a predefined
Start (using a dynamic approach if
maximum if needed
possible)

int array

MAX_LENGTH

Step 2: Input the length of


int length
the array

Length can be any positive


Print "Enter the length of the array:"
integer

Read(length) Step 3: Input array elements

Print "Enter the elements of the array:"

int i = 0

Step 4: Sort the array in


i < length ascending order using Bubble
Sort

True False

Print "Enter element", i + 1, ":" int i = 0

Read(array[i])

Step 5: Display the sorted


i++ i < length - 1
array

True False

int j = 0 Print "Sorted array:"

int i = 0

j < length - i - 1

False True

Swap array[j] and array[j +


i++ array[j] > array[j + 1] i < length
1]

True True False

int temp = array Print(array[i]) End

False array[j] = array i++

j+1

array[j + 1] = temp

j++

You might also like