write a program to display the numbers which are divisible by 2 or 9 between 20 and 50 using for loop
Answers
Answered by
11
Answer: The required java program is :-
public class Main {
public static void main(String[] args) {
System.out.print("The numbers which are divisible by either 2 or 9 between 20 and 50 are : ");
for(int i=21 ; i<50 ; i++) {
if(i%2 == 0) {
System.out.print(i+" ");
}
else if(i%9 == 0) {
System.out.print(i+" ");
}
else {
continue;
}
}
}
}
Please mark it as Brainliest.
Similar questions