Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Bubble Sort ASSIGNMENT: Write a program to sort an array in ascending order. Ask the user to enter 10 double values into an array, in

Bubble Sort ASSIGNMENT: Write a program to sort an array in ascending order. Ask the user to enter 10 double values into an array, in any order. Then, display the un-sorted array values as entered by the user. Sort the array values using a bubble sort. Finally, display the sorted array values. The algorithm for a simple bubble sort is: Create an outer loop that runs 1 time less than the number of elements in the array. This controls the number of passes for the bubble sort. Create an inner loop that runs 1 time less than the number of elements in the array minus the count of the outer loop. This controls the number of comparisons for each pass of the bubble sort. Inside the inner loop, compare adjacent elements. If they are out of order, swap the elements. Remember, to swap array elements, a temporary variable is necessary. Example Run #1: (bold type is what is entered by the user) Enter a value for array element [0]: 5.6 Enter a value for array element [1]: 9.1 Enter a value for array element [2]: 11.5 Enter a value for array element [3]: 3.1 Enter a value for array element [4]: 0.2 Enter a value for array element [5]: 0.8 Enter a value for array element [6]: 1.4 Enter a value for array element [7]: 6.0 Enter a value for array element [8]: 4.7 Enter a value for array element [9]: 7.4 The un-sorted array: 5.60 9.10 11.50 3.10 0.20 0.80 1.40 6.00 4.70 7.40 The sorted array: 0.20 0.80 1.40 3.10 4.70 5.60 6.00 7.40 9.10 11.50 Write in C program. Thanks

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Marketing Database Analytics

Authors: Andrew D. Banasiewicz

1st Edition

0415657881, 978-0415657884

More Books

Students also viewed these Databases questions

Question

=+2 How can the effectiveness of global virtual teams be improved?

Answered: 1 week ago

Question

=+1 What are the major issues related to international T&D?

Answered: 1 week ago