HELLO , EVERY ONE
I HAD EXAM SINCE WEEK AGO
AND THE QUESTION WAS ,( WRITE A PROGRAMME TO SORT AN ARRAY )
CAN ANY ONE WRITE THIS PROBLEM CORRECTLY PLEASE !!
Your code doesn't do any sort of sorting at all (pun not intended), and you don't have an array.
Some info to get you started:
* You will need to create an array
* Sorting would at least involve comparing two elements of the array, as you do with x and y
* Sorting would also involve moving one of x or y to a new position in the array, this depends on the sorting algorithm you're using.
If you had an exam about sorting arrays, I expect you did at least see one or more sorting algorithms in class?
sorry, i didn't noticed that you're using 2 "for" loops, for iterating through the array length, and the 2nd is for iterating as long as the rest of the array. it's pretty much good program, not bad. unless, it contain some logic errors (i think). try to look at this link: http://en.wikipedia.org/wiki/Bubble_sort