Type the programs in NOTEPAD or DOS prompt itself, for Consol Application.
Type in NETBEANS or ECLIPSE for Window Application.
Here after , I am just typing the programs only..to know more about it , refer
Type in NETBEANS or ECLIPSE for Window Application.
Here after , I am just typing the programs only..to know more about it , refer
Introduction to JAVA
before doing any JAVA Programs.
***********************************************************************************************
import java.io.*;
public class ascending
{
public static void main(String args[])throws Exception
{
DataInputStream din=new DataInputStream(System.in);
int t,i,j;
int n=0;
int result=0;
int a[]=new int[10];
System.out.println("Enter the limit :");
n=Integer.parseInt(din.readLine());
System.out.println("Enter the numbers :");
for(i=0;i<n;i++)
{
a[i]=Integer.parseInt(din.readLine());
}
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
if(a[i]<a[j])
{
t=a[i];
a[i]=a[j];
a[j]=t;
}
}
}
System.out.println("The numbers in ascending orer is :");
for(i=0;i<n;i++)
System.out.println(a[i]);
}
}
No comments:
Post a Comment