Ask your own question, for FREE!
Computer Science 9 Online
OpenStudy (anonymous):

Hi, can anyone help me please? Using pseudo code, write an algorithm which will input any three different numbers and then print them out in ascending order.

OpenStudy (istim):

function sort(array) { for (int i = 0; i < 3; i++) { //Check up to array length, start at the first element for(int j= i+1; j < 4; j++) { //Check up to array length + 1, start at the second element. if(a[i] > a[j]) //If the previous element, is greater than the next element in the array, swap it. { temp=a[i]; //Swap variable a[i]=a[j]; a[j]=temp; //Finished swap } } for (int k = 0; k < array.length; k++) { print(a[k]); //Print out the sorted array. } I've written the psuedocode in comments essentially, this is the basic idea. You are swapping elements if they are greater than elements in the array, not sure if you are allowed to use an array or not, but this is a generally accepted solution.

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Latest Questions
Arriyanalol: i need help
1 day ago 7 Replies 1 Medal
Arriyanalol: CONGRATS to me
1 day ago 8 Replies 2 Medals
Legomaster346: What colleges are good that are near Arab Alabama?
1 week ago 5 Replies 0 Medals
Arriyanalol: i need help
1 week ago 6 Replies 2 Medals
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!