Exercise Write a C++ program that reads a maximum of 100 integers from the keyboard, stores them in a long array, sorts the integers in ascending order, and displays sorted output. Input can be...


Exercise<br>Write a C++ program that reads a maximum of 100 integers from the keyboard,<br>stores them in a long array, sorts the integers in ascending order, and displays<br>sorted output. Input can be terminated by any invalid input, such as a letter.<br>HINT:<br>Use the bubble sort algorithm to sort the array. This algorithm repeatedly<br>accesses the array, comparing neighboring array elements and swapping them<br>if needed. The sorting algorithm terminates when there are no more elements<br>that need to be swapped. You use a flag to indicate that no elements have been<br>swapped. Example of bubble sort algorithm:<br>Original array:<br>100<br>50<br>30<br>70<br>40<br>After the first loop:<br>50<br>30<br>70<br>40<br>||<br>100<br>largest element T<br>After the second loop:<br>||<br>30<br>50<br>40<br>70<br>100<br>second largest element<br>

Extracted text: Exercise Write a C++ program that reads a maximum of 100 integers from the keyboard, stores them in a long array, sorts the integers in ascending order, and displays sorted output. Input can be terminated by any invalid input, such as a letter. HINT: Use the bubble sort algorithm to sort the array. This algorithm repeatedly accesses the array, comparing neighboring array elements and swapping them if needed. The sorting algorithm terminates when there are no more elements that need to be swapped. You use a flag to indicate that no elements have been swapped. Example of bubble sort algorithm: Original array: 100 50 30 70 40 After the first loop: 50 30 70 40 || 100 largest element T After the second loop: || 30 50 40 70 100 second largest element

Jun 09, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here