Why on Earth would you use 2 FOR loops with modulus conditioning of single-character variables to explain BREAK statements!?
(If someone comes to this website seeking an explanation about BREAK, then is it fair to assume that the person might have problems understanding your demo?)
public class Break{
public static void main(String[] args){
int i,j;
System.out.println("Prime numbers between 1 to 50 : ");
for (i = 1;i < 50;i++ ){
for (j = 2;j < i;j++ ){
if(i % j == 0)
{
break;
}
}
if(i-1 == j) //THE CORRECTION
{
System.out.print(" " + i);
}
}
}
}
how to get the 2 in output?
Ironic...Wolf_22 August 18, 2011 at 6:05 PM
Why on Earth would you use 2 FOR loops with modulus conditioning of single-character variables to explain BREAK statements!? (If someone comes to this website seeking an explanation about BREAK, then is it fair to assume that the person might have problems understanding your demo?)
code understandingfarhat bouchnak April 30, 2012 at 9:26 PM
hi is it right to use with if only break? please help me and how?
output not correctanoop June 17, 2012 at 11:50 PM
public class Break{ public static void main(String[] args){ int i,j; System.out.println("Prime numbers between 1 to 50 : "); for (i = 1;i < 50;i++ ){ for (j = 2;j < i;j++ ){ if(i % j == 0) { break; } } if(i-1 == j) //THE CORRECTION { System.out.print(" " + i); } } } } how to get the 2 in output?
Post your Comment