Write a program to accept 10 number and Short in ascending
Answers
Answered by
1
Corrected Question:-
- Write a program to accept 10 number in a SDA and sort them in ascending order.
Required Answer:-
//Programming language:Java
//Techniques used: Bubble Sorting
import java.util.*;
class abc {
public static void main (String ar []){
Scanner sc=new Scanner (System.in);
int a[]=new int[10];
//Input
for(int I=0;I<10;I++)
a[i]=sc.nextInt();
//Sorting
for(int I=0;I<10-1;I++)
for(int j=0;j<=10-i-1;j++)
if(a[j]>a[j+1]){
int t=a[j];
a[j]=a[j+1];
a[j]=t;
}
//Printing
System.out.println("Sorted array...");
for(int I=0;I<10;I++)
System.out.print(a[I]+" ");
}
}
Similar questions
English,
1 month ago
Math,
1 month ago
Math,
1 month ago
Hindi,
2 months ago
Environmental Sciences,
2 months ago