Computer Science, asked by anjumsagira57, 4 months ago

write a Java progam to print the series between 0 to 20 with the gap of three i.e. 0 , 3 , 6 , 9 , 12 , 15 , 18​

Answers

Answered by shreyamishra8374
3

Answer:

Java Basic Exercises: Print numbers between 1 to 100 which are divisible by 3, 5 and by both

Sample Solution:

Java Code:

public class Exercise50 {

public static void main(String args[]) {

System.out.println("\nDivided by 3: ");

for (int i=1; i<100; i++) {

if (i%3==0)

System.out.print(i +", ");

}

System.out.println("\n\nDivided by 5: ");

for (int i=1; i<100; i++) {

if (i%5==0) System.out.print(i +", ");

}

System.out.println("\n\nDivided by 3 & 5: ");

for (int i=1; i<100; i++) {

if (i%3==0 && i%5==0) System.out.print(i +", ");

}

System.out.println("\n");

}

}

Explanation:

Similar questions