F1
C
C++
VB
SQL
Java
IP
VP
ALP
Lab
Project
About
Subscribe:
Feeds
RSS
4CSHelp.com
c++ and DS
Prev
Next
skip to main
|
skip to sidebar
Friday, June 18, 2010
PROGRAM TO PRINT PRIME NUMBERS UP TO ‘N’
import java.io.*;
import java.lang.*;
class sorting
{int lim;
int[] n=new int[20];
void read()
{
try
{ DataInputStream in=new DataInputStream(System.in);
System.out.println("Enter the limit");
lim=Integer.parseInt(in.readLine());
System.out.println("Enter the elements");
for(int i=0;i
{
n[i]=Integer.parseInt(in.readLine());
}
}
catch(Exception e)
{
System.out.println("Caught exception"+e);
}
}
void print()
{
for(int i=0;i
{
for(int j=i+1;j
{
if(n[i]>n[j])
{
int temp;
temp=n[i];
n[i]=n[j];
n[j]=temp;
}
}
}
System.out.println("Sorted list is");
for(int i=0;i
{
System.out.println(n[i]);
}
}
}
class sort
{
public static void main(String args[])
{
sorting s=new sorting();
s.read();
s.print();
}
}
0 comments:
Post a Comment
Home
Subscribe to:
Post Comments (Atom)
Blog Archive
▼
2010
(1)
▼
June
(1)
PROGRAM TO PRINT PRIME NUMBERS UP TO ‘N’
Copyright 2009
4CSHelp.com
Design by
Dellustrations
|
Blogger Theme
by
BloggerThemes
0 comments:
Post a Comment