FREE ASSISTANCE FOR THE INQUISITIVE PEOPLE
Tutorial Topics
Find the highest and the lowest character in a word through java Sum of the diagonal elements of 2D Array
Advance Array Examples In Java - Java
2629    Arnab De    11/09/2018

Write a program to input an integer array A[] of n size. Sort the array in ascending order. Then input another number from the user and replace all the numbers less than that inputted number by their reverse.

Example :

If A[] = {38, 25, 16, 91, 5, 12}then, array after sorting is {5, 12, 16, 25, 38, 91} If the number entered = 20 then, after replacing all the numbers less than 20 with their reverse, final Output is {5, 21, 61, 25, 38, 91}

```import java.util.*;
{
public static void main(String []args)
{
int i,j,k,l,p;
Scanner sc=new Scanner(System.in);
System.out.print("Enter A Nos : ");
int n=sc.nextInt();
int []A=new int[n];
System.out.println("Enter A Nos. of Array : ");
for(i=0;i<n;i++)
{
A[i]=sc.nextInt();
}
for(i=0;i<n-1;i++)
{
for(j=i+1;j<n;j++)
{
if(A[i]>A[j])
{
k=A[i];
A[i]=A[j];
A[j]=k;
}
}
}
System.out.println("Sorted Array : ");
for(i=0;i<n;i++)
{
System.out.print(A[i] + "  ");
}
System.out.print("\n Enter A No : ");
k=sc.nextInt();
for(i=0;i<n;i++)
{
if(A[i]<k)
{
if(A[i]>9)
{
l=0;
while(A[i]>0)
{
l=l*10 + (A[i]%10);
A[i] /= 10;
}
A[i]=l;
}
}
else
{
break; //As Array is sorted
}
}
System.out.println("Resultant Array : ");
for(i=0;i<n;i++)
{
System.out.print(A[i] + "  ");
}
}
}
```

Enter the length of Array : 6
Enter A Nos. of Array :
23
43
3
25
19
16
Sorted Array :
3 16 19 23 25 43
Enter A No : 22
Resultant Array :
3 61 91 23 25 43

Find the highest and the lowest character in a word through java Sum of the diagonal elements of 2D Array
Author Details
Arnab De
I have over 16 years of experience working as an IT professional, ranging from teaching at my own institute to being a computer faculty at different leading institute across Kolkata. I also work as a web developer and designer, having worked for renowned companies and brand. Through tutorialathome, I wish to share my years of knowledge with the readers.
Enter New Comment
Comment History
No Comment Found Yet.
It is very simple to be happy, but it is very difficult to be simple.
Rabindranath Tagore
28464
52.77
Today So Far
Total View (Lakh)
26/05/2018     42032
01/01/2018     36003
28/06/2017     34089
25/06/2018     33448
02/08/2017     32401
01/08/2017     26868
06/07/2017     26791
15/05/2017     26418
14/07/2017     21855
21/04/2018     20717