Sunday, December 14, 2008

Program3: sorting array

import java.util.*;

public class array{
public static void main(String[] args){
int num[] = {50,20,45,82,25,63};

int i,j;
System.out.print("Given number : ");
for (i = 0;i <>

{
System.out.print(" " + num[i]);
}


System.out.println("\n");
System.out.print("Accending order number : ");

Arrays.sort(num);

for(i = 0;i <>

{
System.out.print(" " + num[i]);
}
}
}

Program4:

import java.util.*;

public class array{
public static void main(String[] args){
int num[] = {50,20,45,82,25,63};
int l = num.length;
int i,j,t;
System.out.print("Given number : ");
for (i = 0;i <>
System.out.print(" " + num[i]);
}
System.out.println("\n");
System.out.print("Accending order number : ");
Arrays.sort(num);
for(i = 0;i <>
System.out.print(" " + num[i]);
}
}
}

Output of the program:

C:\chandan>javac array.java

C:\chandan>java array
Given number : 50 20 45 82 25 63

Ascending order number : 20 25 45 50 63 82

No comments: