- declare an array of size 5. having name a.
- take input by writing a[b]=EasyIn........ in it using loop having variable name b starting from 0 to a.length and increment by 1
- pass this array to the the method having name methsort like methsort(a);
- write closing curly braces of main method.
- write method like public static void methsort(int[] x)
- write starting curly braces of method methsort.
- initialize a variable e=0;
- start a loop having variable c from 0 to less then 4 and then write starting curly braces of it
- write an other loop having variable name d from 0 to less then 4 and then write starting curly braces of it
- write if(x[d]>x[d+1]) and write starting curly braces of if
- with in the body of if write e=x[d];x[d]=x[d+1];x[d+1]=e; write closing curly braces of if, second loop and first loop.
- For the output write an other loop having variable name f from 0 to 4 and increment by 1. and with in the body of this loop write output statement ..........print(" "+x[f]);
- write closing curly brace of this loop.
This blog is made for my dear class fellows to provide algorithms of different problem statements of JAVA.
Tuesday, 31 January 2012
Sorting using method
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment