§ i: loop counter.
§ A: name of array.
§ n: number of elements of array.
§ pass: for passing the value.
STEP 1: repeat step 2 & 3
For pass 1 to (n-1)
STEP 2: i = 1
STEP 3: repeat while
i <= n-pass
(a) if a [i]>a[i+1] then,
interchange a[i] & a[i+1]
(b) i = i+1
STEP 4: Exit
§ To sort elements of an array, firstly repeat steps 2 & 3 for passes, the element for comparison from 1 to (n-1). Here, 1 is the very first element & (n-1) is the last element of the array.
§ Now, set the loop counter ‘i’ equal to 1 to start the sorting of the element in ascending or descending.
§ After setting loop counter ‘i’ equal to 1, repeat this step until ‘i’ is not greater than or equal to the element of array.
Now, compare the first element with second, and the smaller element will arrange itself in the first place. This comparison will repeat until all the elements of the array are sorted .
§ After comparing every element of the array with other, the loop counter ‘i’ is incremented by 1, each time it compare two values until the condition is satisfied
printf("\nenter array elements");
printf("\nsorted array is");