Java Programs
|
Program to
print prime numbers. |
class primeno
{
public static void main(String args[])
{
int n,i=1,j,c;
n=Integer.parseInt(args[0]);
while(i<=n)
{
c=0;
for(j=1;j<=i;j++)
{
if(i%j==0)
c++;
}
if(c==2)
System.out.print(i);
i++;
}
}
}
|
Output: |

If any
of you want to submit your programs and
contribute to site please mail us at:
citysuvidha@gmail.com
Click here to have a look at List of programs
You can download all the programs in a zip file also. For this you have to do one thing. Just register at the citysuvidha forum and start any thread of any topic. Once you start the thread and put your request, admin will automatically send you the desired zip file.