Computer Science, asked by preksham, 3 months ago

write a java program to enter marks of 7 students in an array and sort the array in descending order using bubble sort technique to print the sorted array​

Answers

Answered by AkashMathematics
0

Answer:

refer

import java.util.Scanner;

class BubbleSortExample {

public static void main(String []args) {

int num, i, j, temp;

Scanner input = new Scanner(System.in);

System.out.println("Enter the number of integers to sort:");

num = input.nextInt();

int array[] = new int[num];

System.out.println("Enter " + num + " integers: ");

for (i = 0; i < num; i++)

array[i] = input.nextInt();

for (i = 0; i < ( num - 1 ); i++) {

for (j = 0; j < num - i - 1; j++) {

if (array[j] < array[j+1])

{

temp = array[j];

array[j] = array[j+1];

array[j+1] = temp;

}

}

}

System.out.println("Sorted list of integers:");

for (i = 0; i < num; i++)

System.out.println(array[i]);

}

}

Answered by moto446
3

Warren Hastings FRS, an English statesman, was the first Governor of the Presidency of Fort William, the head of the Supreme Council of Bengal, and so the first de facto Governor-General of Bengal in 1772–1785. He and Robert Clive are credited with laying the foundation of the British Empire in India.

Similar questions