This is my first ever attempt at writing a program in C++ so don’t expect it to be written well at all, it’s a program which works with arrays and this specific part is a bubble sort program using a 2D array. When I attempt to run the code, the code doesn’t sort (I have had the code sort before but it displayed as a 4×3 array instead of a 3×4 one and I can’t remember what the problem was there) and another value is introduced to the array. I believe the problem is that I’m trying to access elements of the array that don’t exist but I can’t figure out where it’s happening.
Here is my current code, some of it is just displaying values to see what is currently happening in the program:
enter image description here
enter image description here
This is the first few outputs and error message that shows when I try to run the program:
enter image description here
And this is the final output after I press ignore when the error comes up a few times:
enter image description here
I’ve been stuck on this for days now and really can’t figure out what’s going on – it’s probably a simple logic error I’m overlooking and really easily fixed but any help would be appreciated, thank you.
Catriona is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.