Question
In C++ Write a program, which will ask the user how many whole numbers they wish to enter. The program will then read that many
In C++
Write a program, which will ask the user how many whole numbers they wish to enter. The program will then read that many numbers using an array of integers, print them in the order they were entered, sort them in order by increasing value, and print them in sorted order. All numbers entered and displayed will be integer values. All numbers must be validated upon entry. The maximum number of integers to be handled will be 20. Sorting will be done in a function where the array will be the first parameter and the number of integers entered into the array will be the second parameter. Use an array to store the integer values. Use the bubble sort algorithm provided in class.
(Bubble Sort Algorithm)
#include
#include "BubbleSort.h"
void BubbleSort (char Letters [])
{
int i;
bool IsSorted;
int NumChars;
char Temp;
NumChars = strlen (Letters);
do {
IsSorted = true;
NumChars--;
for (i = 0; i < NumChars; i++)
if (Letters [i] > Letters [i + 1])
{
Temp = Letters [i];
Letters [i] = Letters [i + 1];
Letters [i + 1] = Temp;
IsSorted = false;
}
else;
} while (!IsSorted);
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started