Plzz help guys
Write a program to print all the prime no. between 10 to 100
(using loop)
Ankitdudi:
hiii
Answers
Answered by
1
import java.util.Scanner;
public class prime_n0_range
{
public static void main(String args[])
{
int num;
int flag,fac,i;
for(i=10;i<=100;i++)
{
fac=2;
flag=0;
num=i;
while(num>fac)
{
if(num%fac==0)
{
flag=1;
break;
}
else
{
fac++;
}
}
if(flag==0)
{
System.out.println(num+" is a prime number");
}
}
}
}
public class prime_n0_range
{
public static void main(String args[])
{
int num;
int flag,fac,i;
for(i=10;i<=100;i++)
{
fac=2;
flag=0;
num=i;
while(num>fac)
{
if(num%fac==0)
{
flag=1;
break;
}
else
{
fac++;
}
}
if(flag==0)
{
System.out.println(num+" is a prime number");
}
}
}
}
Similar questions