Write a program to input 15 integer elements in an array and sort them in ascending order using the bubble sort technique.
Ans.
import java.io.; import java.util’;
class AscendingOrder {
public static void main(String args[]) {
int i, j, temp;
Scanner sc = new Scanner(System.in);
int arr[] = new int[15];
System.out.println(“Enter 15 integers:”);
for (i = 0; i < = 15; i+ +) { arr[i] = sc.nextlntO; for(i = 0; i < 14; i++){ for(j = 0; j < 14 -i; j + +){ if(arr[j] > arr[j + 1]){
temp = arr[j];
arr[j] = arr [j + 1];
arr[j + 1] = temp;
}
}
}
System.out.println(“Elements in ascending order are::”);
for (i = 0; i < 15; i+ +) {
System.out.println(arr[i]);
}
}
}
}