[Solved] Write a program that uses Bubble Sort to sort integers in a 2 dimensional array in ascending order

You can cast pointer to the first row of a two-dimensional array to pointer to int and sort the array as a one-dimensional array. Here you are #include <iostream> #include <iomanip> #include <cstdlib> #include <ctime> void bubble_sort( int *a, size_t n ) { for ( size_t last /* = n */; not ( n < … Read more

[Solved] Simple Bubble sort program. It works flawlessly about 85% of times but in some cases it doesn’t sort the list

You are not using bubble sort. this is a selection sort algorithm and your code is not correct. I have updated the code for the bubble sort algorithm. #include <stdio.h> #include <stdlib.h> #include <time.h> int main() { int ctr, inner, outer, didSwap, temp; int nums[10]; time_t t; srand(time(&t)); for (ctr = 0; ctr < 10; … Read more