I am given a 4 numbers that I have to input them and use bubble sort to sort them from lowest to highest. This is what I have currently now for the bubble sorting:
void bubble_sort()
{
for (int i=0;i<4;i++)
{
if(num[i]>num[i+1])
{
float temp;
temp=num[i+1];
num[i]=num[i+1];
num[i+1]=temp;
}
}
}
When I output the the array with the inputs: 3.72, 3.92, 3.46, and 3.86 I get : 3.72, 3.46, 3.46, 0