Plzz help guys
Write a program to print all the prime no. between 10 to 100
(using loop)
Share
Plzz help guys
Write a program to print all the prime no. between 10 to 100
(using loop)
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
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");
}
}
}
}