Use app×
Join Bloom Tuition
One on One Online Tuition
JEE MAIN 2025 Foundation Course
NEET 2025 Foundation Course
CLASS 12 FOUNDATION COURSE
CLASS 10 FOUNDATION COURSE
CLASS 9 FOUNDATION COURSE
CLASS 8 FOUNDATION COURSE
+1 vote
15.3k views
in Computer by (49.9k points)
closed by

Write a program to input 15 integer elements in an array and sort them in ascending order using the bubble sort technique.

1 Answer

+3 votes
by (48.9k points)
selected by
 
Best answer

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]); 

}

by (10 points)
Helpful

Welcome to Sarthaks eConnect: A unique platform where students can interact with teachers/experts/students to get solutions to their queries. Students (upto class 10+2) preparing for All Government Exams, CBSE Board Exam, ICSE Board Exam, State Board Exam, JEE (Mains+Advance) and NEET can ask questions from any subject and get quick answers by subject teachers/ experts/mentors/students.

Categories

...