- 2

How to print prime number between 1 to 100 in java by using do while loop?

Program must contains do while loop.

17th Sep 2019, 1:14 PM
punam gaikwad
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); } }
17th Sep 2019, 3:02 PM
KfirWe
KfirWe - avatar
- 2
In descending order
18th Sep 2019, 3:38 PM
punam gaikwad