Introduction
In this blog, I will explain about Descending order (Number) program, using Java. It is very simple in Java programming. The output will be displayed in the Run module.
Software Requirement
JDK1.3.
Simple program
- import java.io.*;
-
- class dsc
- {
- public static void main (String arg[])
- {
- int i,j,t;
- int a[] = {4,2,1,5,8};
-
- for(i=0;i<=a.length;i++)
- {
- for(j=i+1;j<=a.length-1;j++)
- {
- if(a[i] < a[j])
- {
- t = a[i];
- a[i] = a[j];
- a[j] = t;
- }
- }
- }
- for(i=0;i<10;i++)
- {
- System.out.println(+a[i]+"\n");
- }
- }
- }
Explanation
In this blog, I will explain about the descending order (numbers) program, using Java. The output will be displayed in the Run module.
Output