0

A program that displays all the numbers from 100 to 200 that are divisible by 5 or 6, but not both

29th Oct 2017, 10:01 AM
Ayesha
Ayesha - avatar
3 Answers
+ 7
take a look at the logical XOR operator (^) https://stackoverflow.com/questions/726652/creating-a-logical-exclusive-or-operator-in-java would be really helpful for that code you wrote
29th Oct 2017, 10:07 AM
Kamil
Kamil - avatar
+ 1
in addition to above answer use continue statement in the first for loop
29th Oct 2017, 10:04 AM
Nanda Balakrishnan
0
public class Program { public static void main(String[] args) { for(int i=100;i<200;i++){ if((i%5==0)&&(i%6==0)) {System.out.println();} if((i%5==0)||(i%6==0)) {System.out.print(i+ " ");} } } }
29th Oct 2017, 10:01 AM
Ayesha
Ayesha - avatar