I am creating 30 random from last function and the last function have pass the information to this one. I am using the bubble sort because i want to make a mode. But mode is not idea here. Anyway, it run but it show some crazy output. Here is the output:
-1969384903, -1969384675, -1957005749, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
here is the random number:
17-78-81-10-98-67-30-87-63-15
73-63-50-51-61-89-20-89-27-1
6-56-47-91-35-16-97-13-39-81
can someone tell me what i did wrong?
void mode(int mode[],int size2)
{
int sorting_array[size2];
int swap = 0;
for(int counter = size2-1; counter >= 0 ; counter --)
{
for (int index = 0 ; index < size2; index ++)
{
if (sorting_array[index] > sorting_array[index + 1])
{
swap = sorting_array [index + 1];
sorting_array [index + 1] = sorting_array [index] ;
sorting_array[index] = swap;
}
}
}
for (int index = 0 ; index < 30; index ++)
{
cout << sorting_array[index] << ", ";
}