Hi, everyone, this is my first time posting here, and I was hoping to get some advice for a homework assignment I have.
My assignment is to make a bubble sort array in ascending order using user input for up to 20 integers.
so far I've been pretty good writing the code up to this point, using google and other resources. But now I'm lost as to why my code is not actually sorting the array when it is run and all the values are put in by the user.
I would really appreciate it if anyone could give me a nudge in the right direction or a link to a good tutorial on this kind of stuff. I don't want anyone to just solve it for me as that won't help me learn what I'm doing wrong. thanks in advance
#include "bubble.h"
#include<string.h>
#include<iostream>
void bubblesort(int numbers[],int max_size)
{
int j;
int Num;
char temp;
bool IsSorted;
do {
IsSorted = true;
Num--; // tells the loop that the last item does not need to be looked at again since that item is already sorted from the previous loop
for (j = 0; j < Num; j++) //loops each time for how many elements of the aray we have
{
if (numbers[j] > numbers[j + 1])
{
temp = numbers[j];
numbers[j] = numbers[j + 1];
numbers[j + 1] = temp;
IsSorted = false;
}
else;
}
} while (!IsSorted); //as long as IsSorted is false it will loop and swap
}