how to practice Code?
practice code?
Under discussion
Comments (2)
- Popular
- New
- Old
You must be signed in to leave a comment
Hruthish
15 December 2022, 01:53
import java.io.*;
class Prime
{
public static void main(String args[])throws IOException
{
int a,b,i,j,flag;
DataInputStream ds=new DataInputStream(System.in)
System.out.println("Enter lower bound of the interval:");
a=Integer.parseInt(ds.readLine());
System.out.println("Enter upper bound of the interval:");
b=Integer.parseInt(ds.readLine());
System.out.println("/n Prime number between "+a+" and "+b+" are:");
for(i=a;i<=b;i++)
{
if(i=1||i=0)
continue;
flag=0;
for(j=2;j<=i/2;j++)
{
if(i/j==0)
{
flag=1
break;
}
}
if(flag==0
System.out.println(i);
}
}
}
0
Thomas
15 December 2022, 10:52
0