- 2
How to print prime number between 1 to 100 in java by using do while loop?
Program must contains do while loop.
2 Respuestas
+ 2
public class gfhugdsau
{
public static void isprime(int num){
boolean flag = false;
for(int i = 2; i <= num/2;i++)
{
if(num==i){
continue;
}
if(num % i == 0)
{
flag = true;
break;
}
}
if (!flag){
System.out.println(num + " is a prime number.");
}
}
public static void main(String[] args)
{
int i=0;
do{
isprime(i);
i++;
}while(i<=100);
}
}
- 2
In descending order