Computer Science, asked by Mohammad9082, 1 year ago

write a program which accept 10 integers in an arrey and then arrange the aerry in ascending order

Answers

Answered by Anonymous
1
import java.io.*;
class Array
{
 public static void main()throws IOException
{
     int n;   
  DataInputStream di=new DataInputStream(System.in); 
   System.out.println("enter the value of n");
     n=Integer.parseInt(di.readLine()); 
    int a[]=new int[n];
    System.out.println("enter n numbers in array");
  for(int i=0;i<n;i++) 
 {
a[i]=Integer.parseInt(di.readLine());
}


for (int i = 0; i < n-1; i++)
{   
        for (int j = 0; j < n-i-1; j++)     
        {
                if (a[j] > a[j+1])             
   {                               
      int temp = a[j];                 
         a[j] = a[j+1];             
       a[j+1] = temp;   
             }
    }
}


 for(int i=0;i<n;i++)
  { 
System.out.println(a[i]);}
}

}
}

Anonymous: plz mark it as brainliest
Similar questions