Computer Science, asked by Rabiasiddiqua, 7 months ago

write a program to accept a word in a single dimensional array. Arrange all the alphabet in ascending order.
sample input- BLUEJ
sample output- BEJLU​

Answers

Answered by tanaychowdary
2

Answer:

import java.util.Scanner;

public class ExArraySort

{

public static void main(String args[])

{

// initialize the objects.

int n, i, j, temp;

int arr[] = new int[50];

Scanner scan = new Scanner(System.in);

// enter number of elements to enter.

System.out.print("Enter number for the array elements : ");

n = scan.nextInt();

// enter elements.

System.out.println("Enter " +n+ " Numbers : ");

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

{

arr[i] = scan.nextInt();

}

// sorting array elements.

System.out.print("Sorting array : \n");

for(i=0; i<(n-1); i++)

{

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

{

if(arr[j] > arr[j+1])

{

temp = arr[j];

arr[j] = arr[j+1];

arr[j+1] = temp;

}

}

}

System.out.print("Array Sorted Successfully..!!\n");

// array in ascending order.

System.out.print("Sorted List in Ascending Order : \n");

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

{

System.out.print(arr[i]+ " ");

}

}

}

Output

Enter number for the array elements : 10

Enter 10 Numbers :

25

54

36

12

48

88

78

95

54

55

Sorting array :

Array Sorted Successfully..!!

Sorted List in Ascending Order :

12 25 36 48 54 54 55 78 88 95

Answered by araj13
1

program in python

word=input("Enter a string:")

order=word.split()

word.sort()

print("The arranged words are:")

for word in order:

print(word)

plz follow me

Similar questions