Kumar
BAN USER
Comments (4)
Reputation 0
Page:
1
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
0
of 0 vote
import java.util.Scanner;
public class Prime {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int a = s.nextInt();
int b = s.nextInt();
int counter;
System.out.println("Displaying Prime numbers between " + a + " and " + b);
for(int i = a; i <= b; i++) {
counter=0;
for(int j=2;j<i;j++)
{
if(i%j==0)
counter=1;
}
if(counter==0) {
System.out.println(i);
}
}
}
}
Comment hidden because of low score. Click to expand.
Page:
1
CareerCup is the world's biggest and best source for software engineering interview preparation. See all our resources.
I think this piece of code might work
- Kumar November 06, 2012for (DICTIONARY words : EnumSet Range (words.CAT, words.DOG))
System.out.println(words);