### Bubble Sort Crashing

This project is for my intro programming course. After entering the numbers it crashes. I would assume the nested for loops or the bubble sort portions are causing this. I just need a 2nd pair of eyes to tell me what I'm doing wrong.

 ``123456789101112131415161718192021222324252627`` ``````// Pseudocode PLD Chapter 8 #1 pg. 350 // Start // Declarations // num SIZE = 10 // num NUMBERS[10] // num i // num j // num temp // for i = 0 to SIZE - 1 // output "Please enter a number: " // input NUMBERS[i] // endfor // for i = 0 to SIZE - 2 // for j = 0 to SIZE - 2 // if (NUMBERS[j] > NUMBERS[j+1]) // temp = NUMBERS[j] // NUMBERS[j] = NUMBERS[j+1] // NUMBERS[j+1] = temp // endif // endfor // endfor // output "Sorted List" // output "===========" // for i = 0 to SIZE - 1 // output "Number ", i + 1, ": ", NUMBERS[i] // endfor // Stop ``````

 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445`` ``````#include #include using namespace std; int main() { int SIZE = 10; int NUMBERS[10]; int i; int j; int temp; for(i = 0; i <= SIZE-1; i++) { cout << "Please enter a number: " ; cin >> NUMBERS[i]; } for(i = 0; i <= SIZE-2; i++) { for(j = 0; i <= SIZE-2; j++) { if(NUMBERS[j] > NUMBERS[j+1]) { temp = NUMBERS[j]; NUMBERS[j] = NUMBERS[j+1]; NUMBERS[j+1] = temp; } } } cout << "Sorted List" << endl; cout << "===========" << endl; for(i = 0; i <= SIZE-1; i++) { cout << "Number " << i + 1 << ": " << NUMBERS[i] << endl; } system ("PAUSE"); return 0; }``````
change this `for(j = 0; i <= SIZE-2; j++)`

to this
`for(j = 0; j <= SIZE-2; j++)`

`for(j = 0; i <= SIZE-2; j++)`

Spot the error!
HA!

I knew it was something ridiculously easy and stupid on my part. TYVM!
@Giggidy
Your loop should be like this>
`for(j = 0; j <= SIZE-2-i; j++)`
Topic archived. No new replies allowed.